EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Question about displaying process memory allocation on Linux
From: Mark Rivers <[email protected]>
To: 'Andrew Johnson' <[email protected]>, "[email protected]" <[email protected]>
Date: Tue, 26 Jun 2018 16:23:25 +0000
Hi Andrew,

Thanks for the hint.  

I was able to get the memory released back to the OS simply by setting the environment variable MALLOC_TRIM_THRESHOLD_ to a small value (1024) before starting the IOC.

Previously the VSZ, DRS, and RSS did not decrease much at all when I called emptyFreeList().

After setting MALLOC_TRIM_THRESHOLD_ to 1024 and collecting a bunch of arrays that allocate 3GB on the free list I see this, the same as before.

corvette:dxpSITORO/iocBoot/iocFalconX1>ps -p 145432 -o trs,vsz,drs,rss
 TRS    VSZ   DRS   RSS
15838 8321936 8306097 3237400

However, now after I call emptyFreeList() I see this.
corvette:dxpSITORO/iocBoot/iocFalconX1>ps -p 145432 -o trs,vsz,drs,rss
 TRS    VSZ   DRS   RSS
15838 5173204 5157365 88668

Note that the memory allocation has indeed decreased by 3GB, so the memory has been given back to the OS.

Thanks,
Mark



-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Andrew Johnson
Sent: Tuesday, June 26, 2018 11:02 AM
To: [email protected]
Subject: Re: Question about displaying process memory allocation on Linux

Hi Mark,

On 06/26/2018 08:51 AM, Mark Rivers wrote:
> This is what I see after I process the EmptyFreeList record.  Note 
> that VSZ has only decreased by about 0.2GB, not by 3GB which I would 
> have expected.  Can anyone explain?
> 
> corvette:dxpSITORO/iocBoot/iocFalconX1>ps -p 115038 -o trs,vsz,drs
> 
> TRS    VSZ   DRS
> 
> 15838 7974816 7958977

On linux (using glibc) the C runtime library won't return memory back to the OS by default, but you can ask it to do so. The first answer to this StackOverflow question gives some explanation and pointers:

https://stackoverflow.com/questions/2215259/will-malloc-implementations-return-free-ed-memory-back-to-the-system

HTH,

- Andrew

--
Arguing for surveillance because you have nothing to hide is no different than making the claim, "I don't care about freedom of speech because I have nothing to say." -- Edward Snowdon

References:
Question about displaying process memory allocation on Linux Mark Rivers
Re: Question about displaying process memory allocation on Linux Andrew Johnson

Navigate by Date:
Prev: Re: Question about displaying process memory allocation on Linux Andrew Johnson
Next: RE: Question about displaying process memory allocation on Linux Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Question about displaying process memory allocation on Linux Andrew Johnson
Next: 'assert (pca->pgetNative)' failed in ../dbCa.c [email protected]
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
ANJ, 27 Jun 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·