digitalmars.D - GC and cleaning out Windows system resources
- Stewart Gordon (24/24) Sep 13 2004 Those who've been following SDWF'll know that it uses destructors and
- Nigel Sandever (12/42) Sep 13 2004 There is a performace data counter that may help:
- Stewart Gordon (12/16) Sep 17 2004 Alas, Win98 doesn't have it. I noticed that it has HKEY_DYN_DATA, but
Those who've been following SDWF'll know that it uses destructors and hence GC to free GDI resources. However, there doesn't seem to be a way of making the GC automagically run when Windows gets low on resources. I've started to try creating the object, and if it fails, running GC and then trying again. But this leaves freeing resources to the last minute, which can cause other apps or even the whole system to crash in the meantime. There therefore ought to be a way of catching a shortage of system resources before it gets to zero, in order to try GCing and freeing them up. I haven't been able to find a Win32 function in Win9x that interrogates the levels of free resources, but obviously there's a way of doing it as Resource Meter and the System Properties section of Control Panel do. That aside, one possibility I can see is to fit GC passes into the message loop. Collecting on processing every message would be a bit inefficient, but I can see a possibility. Maybe count the messages despatched, and after every (say) 100, do a genCollect. Moreover, pauses could be absorbed by waiting till 100 messages have gone through _and_ the message queue is empty (using PeekMessage), then doing GC. Does anyone have a better idea? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 13 2004
On Mon, 13 Sep 2004 16:37:35 +0100, Stewart Gordon <smjg_1998 yahoo.com> wrote:Those who've been following SDWF'll know that it uses destructors and hence GC to free GDI resources. However, there doesn't seem to be a way of making the GC automagically run when Windows gets low on resources. I've started to try creating the object, and if it fails, running GC and then trying again. But this leaves freeing resources to the last minute, which can cause other apps or even the whole system to crash in the meantime. There therefore ought to be a way of catching a shortage of system resources before it gets to zero, in order to try GCing and freeing them up. I haven't been able to find a Win32 function in Win9x that interrogates the levels of free resources, but obviously there's a way of doing it as Resource Meter and the System Properties section of Control Panel do.There is a performace data counter that may help: 260: Objects The Object performance object consists of counters that monitor logical objects in the system, such as processes, threads, mutexes, and semaphores. This information can be used to detect the unnecessary consumption of computer resources. Each object requires memory to store basic information about the object. This is accessed through the (psuedo-) registry key HKEY_PERFORMANCE_DATA (see WinPerf.h for details. Whether this is available for 95/98/ME I'm unsure.That aside, one possibility I can see is to fit GC passes into the message loop. Collecting on processing every message would be a bit inefficient, but I can see a possibility. Maybe count the messages despatched, and after every (say) 100, do a genCollect. Moreover, pauses could be absorbed by waiting till 100 messages have gone through _and_ the message queue is empty (using PeekMessage), then doing GC. Does anyone have a better idea? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 13 2004
Nigel Sandever wrote: <snip>This is accessed through the (psuedo-) registry key HKEY_PERFORMANCE_DATA (see WinPerf.h for details. Whether this is available for 95/98/ME I'm unsure.Alas, Win98 doesn't have it. I noticed that it has HKEY_DYN_DATA, but that has nothing of relevance to be seen. Does anyone have any idea why M$ deleted GetFreeSystemResources and provided no replacement? Maybe this'll help though.... http://tinyurl.com/3o2z5 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Sep 17 2004