<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Vector doesn't release memory in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095208#M92322</link>
    <description>HP-Unix 11.2&lt;BR /&gt;aCC 5.5&lt;BR /&gt;&lt;BR /&gt;I use lots of vector(STL vector) in my source code to store the object return from database. Recently I find an issue that the vector doesn't release its memory even leaves its scope. But the issue doesn't rise at linux platform(Redhat AS3, gcc 3.2). Someone side that the vector will keep some memory as memory pool till the process die. But it seem to can't answer my question. My program can keep memory even more than 1G. How big a pool!??&lt;BR /&gt; &lt;BR /&gt;I want to know why and how can I fix the problem. &lt;BR /&gt;&lt;BR /&gt;My testing code is as below:&lt;BR /&gt;&lt;BR /&gt;testFun()&lt;BR /&gt;{&lt;BR /&gt;  string str = "aaaaaaaa";&lt;BR /&gt;  vector&lt;STRING&gt; aVect;&lt;BR /&gt;  for(long i=0;i&amp;lt;1024*1024;i++)&lt;BR /&gt;  {&lt;BR /&gt;    aVect.push_back(str);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;  aVect.clear();&lt;BR /&gt;  vector&lt;STRING&gt;().swap(aVect);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;  for(int i=0;i&amp;lt;1024;i++)&lt;BR /&gt;  {&lt;BR /&gt;    testFun();&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The source code above will let the memory of process rise and won't free it till the process out of life(HP-Unix 11.2, aCC 5.5).&lt;BR /&gt;The issue won't rise at linux(Redhat AS3, gcc 3.2)&lt;BR /&gt;&lt;BR /&gt;&lt;/STRING&gt;&lt;/STRING&gt;</description>
    <pubDate>Wed, 31 Oct 2007 10:41:12 GMT</pubDate>
    <dc:creator>kantaguo</dc:creator>
    <dc:date>2007-10-31T10:41:12Z</dc:date>
    <item>
      <title>Vector doesn't release memory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095208#M92322</link>
      <description>HP-Unix 11.2&lt;BR /&gt;aCC 5.5&lt;BR /&gt;&lt;BR /&gt;I use lots of vector(STL vector) in my source code to store the object return from database. Recently I find an issue that the vector doesn't release its memory even leaves its scope. But the issue doesn't rise at linux platform(Redhat AS3, gcc 3.2). Someone side that the vector will keep some memory as memory pool till the process die. But it seem to can't answer my question. My program can keep memory even more than 1G. How big a pool!??&lt;BR /&gt; &lt;BR /&gt;I want to know why and how can I fix the problem. &lt;BR /&gt;&lt;BR /&gt;My testing code is as below:&lt;BR /&gt;&lt;BR /&gt;testFun()&lt;BR /&gt;{&lt;BR /&gt;  string str = "aaaaaaaa";&lt;BR /&gt;  vector&lt;STRING&gt; aVect;&lt;BR /&gt;  for(long i=0;i&amp;lt;1024*1024;i++)&lt;BR /&gt;  {&lt;BR /&gt;    aVect.push_back(str);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;  aVect.clear();&lt;BR /&gt;  vector&lt;STRING&gt;().swap(aVect);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;  for(int i=0;i&amp;lt;1024;i++)&lt;BR /&gt;  {&lt;BR /&gt;    testFun();&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The source code above will let the memory of process rise and won't free it till the process out of life(HP-Unix 11.2, aCC 5.5).&lt;BR /&gt;The issue won't rise at linux(Redhat AS3, gcc 3.2)&lt;BR /&gt;&lt;BR /&gt;&lt;/STRING&gt;&lt;/STRING&gt;</description>
      <pubDate>Wed, 31 Oct 2007 10:41:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095208#M92322</guid>
      <dc:creator>kantaguo</dc:creator>
      <dc:date>2007-10-31T10:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Vector doesn't release memory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095209#M92323</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Can't help you with the code.&lt;BR /&gt;&lt;BR /&gt;Can help you be sure this program is the leaker.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/?p=8" target="_blank"&gt;http://www.hpux.ws/?p=8&lt;/A&gt;&lt;BR /&gt;Memory leak detector.&lt;BR /&gt;&lt;BR /&gt;It works on HP-UX and Red Hat, so test it on both.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 31 Oct 2007 11:14:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095209#M92323</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-10-31T11:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Vector doesn't release memory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095210#M92324</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Memory that is free()'d in HP-UX is not returned to the operating system until the process terminates.  Instead, the deallocated memory is returned to the "heap" for reuse by the owning process if it allocates memory again.  Hence, the memory footprint of a process will rarely shrink, but will seems to remain static or will grow with increased allocation.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 31 Oct 2007 11:50:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095210#M92324</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-31T11:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Vector doesn't release memory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095211#M92325</link>
      <description>Clay, SEP and JRF are correct.  The freed space is put back in the heap for later reuse.&lt;BR /&gt;&lt;BR /&gt;Adding a call to sbrk(2) in the outer for-loop indicates no leaks.  Purify beta on IPF indicates no leaks either.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;My program can keep memory even more than 1G. How big a pool!??&lt;BR /&gt;&lt;BR /&gt;Well, as big as your heap high water mark.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;HP-Unix 11.2, aCC 5.5).&lt;BR /&gt;&lt;BR /&gt;I assume you are on 11.23.  Note aCC5 is no longer supported.  The latest is A.06.15.</description>
      <pubDate>Wed, 31 Oct 2007 20:53:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095211#M92325</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-10-31T20:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Vector doesn't release memory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095212#M92326</link>
      <description>Thank you for your replies.&lt;BR /&gt;&lt;BR /&gt;I have known the feature that vector will keep the memory allocated as a memory pool in order to enhance the performance of memory allocation. Sometime I use the vector to store very large data(more than 1G), but the large data isn't used frequent. It means that most of the time the memory keeped by the progess is idle. And so large memory usage let my system and platform slowdown.&lt;BR /&gt;&lt;BR /&gt;Can I forbid the memory pool,let the vector free memory immediatelyï¼ &lt;BR /&gt;&lt;BR /&gt;It need a special global valiable, compiler option or any other configuration?&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Nov 2007 09:12:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095212#M92326</guid>
      <dc:creator>kantaguo</dc:creator>
      <dc:date>2007-11-01T09:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Vector doesn't release memory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095213#M92327</link>
      <description>&amp;gt;And so large memory usage let my system and platform slowdown.&lt;BR /&gt;&lt;BR /&gt;Do you have any proof of that?  This should only waste swap space and the "idle" pages should just be paged out.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Can I forbid the memory pool, let the vector free memory immediately?  It needs a special global variable or any other configuration?&lt;BR /&gt;&lt;BR /&gt;Probably not.  This is a libc issue.  As Clay mentioned, you could try:&lt;BR /&gt;mallopt(M_REL_LAST_FBLK, 1);</description>
      <pubDate>Thu, 01 Nov 2007 15:34:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vector-doesn-t-release-memory/m-p/4095213#M92327</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-01T15:34:21Z</dc:date>
    </item>
  </channel>
</rss>

