To the Ineffable All,
I was wondering if someone can settle once and for all whether or not failing to do a LocalFree for every LocalAlloc results in memory that is unusable until a fresh reboot. In other words, after a program that uses LocalAlloc finishes its execution, is the O/S smart enough to release any memory assigned to the program? Please do not answer this question if you do not know for sure. Or if you do answer this post and don't know for sure, say you do not know for sure. And what about file handles and device contexts? Thanks, Ratch
Ratch,
It has been the case in win32 differing from win16 that when the program exits, the OS recovers any allocated memory. Where you can get into trouble with a memory leak is while the app is still running as it may exceed what is available over a long period or if it is being leaked at high speed in a loop.
Absolutely, the memory is freed. There is no distinction between LOCAL and GLOBAL heaps in Win32 and part of LdrShutdownProcess is a heap walk using RtlWalkHeap that systematically frees all objects, memory and other that are created by the process as well as invalidating any handles used. Actually during the call to RtlValidateprocessHeaps which is part of the ExitProcess function, the OS will obtain information on each heap allocated to a process and call NtlFreeVirtualMemory for each one. So yes, all the memory is freed.
hutch-- and donkey,
Thank you both for your definitive answers. And also any others of the Ineffable All who might participate in this thread later. Ratch
Ratch,
When I first saw the topic, I thought there was someone else with advanced senile decay. :bg
Personally, I would consider it an honor to be a member of that club.
Paul
I used to be a member of that club..... I think... err.... wait.... what were we talking about again?
My membership starts this morning when i wake up with my head, too heavy for my shoulders after last night's vodkin' holiday :bg
"50 watts per channel, baby-cakes!" :toothy
And definitely with surround effect, Mark ::)