473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

garbage collection and calling dll's (eg win32 api)

Hi,

I have a few related questios:

1. if I pass a string to win32 api (or other dll not written in .net), is it
possible GC cleans up while function is still busy ? eg:

public class Win32
{
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(string ClassName, string
WindowName);

And call it:

IntPtr Win = Win32.FindWindow(ClassName, null);

2. Does it make a difference if ClassName is a literal inside the exe,
because in that case the string is only a pointer to something in read only
mem, so no memory allocation, eg:

string ClassName = "theclass";
IntPtr Win = Win32.FindWindow(ClassName, null);

3. Is it possible to block the GC for a while, for example if I have time
critical code to execute, I dont want to let GC slow down machine if there is
a lot to clean up ?

--
rgds, Wilfried
http://www.mestdagh.biz
Nov 16 '05 #1
1 1559
Wilfried,
1. if I pass a string to win32 api (or other dll not written in .net), is it
possible GC cleans up while function is still busy ?
No.

2. Does it make a difference if ClassName is a literal inside the exe,
No

because in that case the string is only a pointer to something in read only
mem, so no memory allocation, eg:
The string is still allocated from the GC heap.

3. Is it possible to block the GC for a while, for example if I have time
critical code to execute,
No.

I dont want to let GC slow down machine if there is
a lot to clean up ?


I wouldn't worry about that unless you've actually measured the time
used by GC and determined that it's a problem.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: EKL | last post by:
What do I have to do to guarantee that the objects that my code creates are reclaimed by only minor garbage collection runs? In other words, what do I have to do to only generate garbage for minor...
2
by: Peter Kwan | last post by:
Hi, I believe I have discovered a bug in Python 2.3. Could anyone suggest a get around? When I tested my existing Python code with the newly released Python 2.3, I get the following warning: ...
34
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
55
by: jacob navia | last post by:
Tired of chasing free(tm) bugs? Get serious about C and use lcc-win32. The garbage collector designed by Boehm is the best of its class. Very simple: #define malloc GC_malloc #define free(a)...
28
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will...
142
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory...
3
by: cbmeeks | last post by:
I think I know the answer to this but I would like to confim. I have an app where I've built a custom DataSet containing several DataTables. Within the DataTables, I sometimes check for...
7
by: jwmaiden | last post by:
I'm running a vb.net application that calls a dll written in unmanaged c++, and wondering about the effects of Garbage Collection on the program. As far as I know, garbage collection is pretty much...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.