- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Vector doesn't release memory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 03:41 AM
тАО10-31-2007 03:41 AM
Vector doesn't release memory
aCC 5.5
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!??
I want to know why and how can I fix the problem.
My testing code is as below:
testFun()
{
string str = "aaaaaaaa";
vector
for(long i=0;i<1024*1024;i++)
{
aVect.push_back(str);
}
aVect.clear();
vector
}
int main()
{
for(int i=0;i<1024;i++)
{
testFun();
}
}
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).
The issue won't rise at linux(Redhat AS3, gcc 3.2)
- Tags:
- heap usage
- vector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 04:14 AM
тАО10-31-2007 04:14 AM
Re: Vector doesn't release memory
Can't help you with the code.
Can help you be sure this program is the leaker.
http://www.hpux.ws/?p=8
Memory leak detector.
It works on HP-UX and Red Hat, so test it on both.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 04:50 AM
тАО10-31-2007 04:50 AM
Re: Vector doesn't release memory
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.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2007 01:53 PM
тАО10-31-2007 01:53 PM
Re: Vector doesn't release memory
Adding a call to sbrk(2) in the outer for-loop indicates no leaks. Purify beta on IPF indicates no leaks either.
>My program can keep memory even more than 1G. How big a pool!??
Well, as big as your heap high water mark.
>HP-Unix 11.2, aCC 5.5).
I assume you are on 11.23. Note aCC5 is no longer supported. The latest is A.06.15.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2007 02:12 AM
тАО11-01-2007 02:12 AM
Re: Vector doesn't release memory
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.
Can I forbid the memory pool,let the vector free memory immediately├п┬╝
It need a special global valiable, compiler option or any other configuration?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2007 08:34 AM
тАО11-01-2007 08:34 AM
Re: Vector doesn't release memory
Do you have any proof of that? This should only waste swap space and the "idle" pages should just be paged out.
>Can I forbid the memory pool, let the vector free memory immediately? It needs a special global variable or any other configuration?
Probably not. This is a libc issue. As Clay mentioned, you could try:
mallopt(M_REL_LAST_FBLK, 1);