Web lists-archives.com

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




> Cc: mingw-users@xxxxxxxxxxxxxxxxxxxxx
> From: Emanuel Falkenauer <E.Falkenauer@xxxxxxxxxxxxxxxxx>
> Date: Fri, 5 May 2017 19:13:42 +0200
> 
> > 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.

I don't understand what you mean by "accumulated over multiple runs of
the same binary".  The OS has no way of knowing whether the same
binary will be run again once its process terminates, so it cannot
keep that process's memory "reserved" when the process no longer
exists.  Moreover, modern Windows systems randomize the memory of a
binary, so each run of the same binary will have different addresses
allocated to it for the same code calling 'malloc'.  In this
situation, accumulating memory over multiple runs makes even less
sense.

Once again, please show your evidence, in the form of running a
program and looking at the system memory with some tool, which would
show that some of the memory which was allocated by a process calling
'malloc' is still marked as used after it terminates.  I'm quite sure
you draw erroneous conclusions from whatever observations you made,
but it's impossible to point out specific mistakes without knowing the
details.

------------------------------------------------------------------------------
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
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
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:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe