Web lists-archives.com

Re: [Mingw-users] CRT lib: potential memory leakage

On 05-May-17 18:12, Eli Zaretskii wrote:
>> From: Emanuel Falkenauer <E.Falkenauer@xxxxxxxxxxxxxxxxx>
>> Date: Fri, 5 May 2017 17:20:03 +0200
>>> First, what is the purpose of freeing memory just before the program
>>> exits?  That memory will be freed by the OS anyway.
>> Disagree. It is my sad experience that Windows in particular does NOT
>> free all memory allocated in an exiting binary - it probably should, but
>> does NOT. We learned it the hard way, getting gigs of RAM "reserved"
>> (but not freed), until we found a few arrays we didn't free just before
>> leaving, and the thing was accumulating over multiple runs of the same
>> binary.
> AFAIK, "reserved" memory is freed once the program exits, because it
> is reserved for the process.  If you have evidence that this doesn't
> happen, please show a program that can be used to demonstrate this.
> I think what you saw is that memory freed by calling 'free' still
> stays "reserved", and is not returned to the OS.  This is normal, but
> it only happens as long as the process still runs.

Somehow I expected that answer - which is precisely why I said "it 
accumulates over multiple runs of the same binary". If it really worked 
as you say (and probably should), then the same memory should be reused 
in all the runs after the first, i.e. NOT accumulate into gigs of RAM.

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe