|
|
|
|
|
|
| Author |
Message |
jithoosin *nix forums beginner
Joined: 21 Jul 2006
Posts: 6
|
Posted: Fri Jul 21, 2006 9:12 am Post subject:
Where is this code not freeing memory ?
|
|
|
Hi
Let me first of all tell that this problem is not specific to a
compiler like gcc. It even comes in windows. So dont regard the
question as off topic.
I am posting a code using stl. I viewed the memory for program
by giving top command
eg: top -d 0.2 -p 'pid'
The pid will be printed out by the program itself.
Now coming to the question. The code is supposed to take around (200000
* 100 * 4 bytes = 76MB) .The top command at halfway point (line 41)
showed around 80MB. Until now it is correct. But after this i start
deleting elements from vector one by one. Then the code is supposed to
take lesser memory. But the top command showed still 80MB. Why is this
?
I then googled and read in
http://www-1.ibm.com/support/docview.wss?rs=994&context=SSSHAD&dc=DB5...
that stl "caches" memory and they gave a work around for it. I tried in
the code. Even that is not working.
Let me tell that valgrind or purify is not showing any leak in the
code. I some how need to free
from stl the memory. Is there any way ? Could any one help me ? I need
a general solution which is applicable for all stl containers. I cannot
wait for the program to terminate as i need to make more allocations
later
Thanks in advance
Regards
Kiran Pradeep |
|
| Back to top |
|
 |
Kai-Uwe Bux *nix forums Guru
Joined: 06 May 2005
Posts: 627
|
Posted: Fri Jul 21, 2006 12:43 pm Post subject:
Re: Where is this code not freeing memory ?
|
|
|
jithoosin wrote:
| Quote: | Hi
Let me first of all tell that this problem is not specific to a
compiler like gcc. It even comes in windows. So dont regard the
question as off topic.
I am posting a code using stl. I viewed the memory for program
by giving top command
eg: top -d 0.2 -p 'pid'
The pid will be printed out by the program itself.
Now coming to the question. The code is supposed to take around (200000
* 100 * 4 bytes = 76MB) .The top command at halfway point (line 41)
showed around 80MB. Until now it is correct. But after this i start
deleting elements from vector one by one. Then the code is supposed to
take lesser memory. But the top command showed still 80MB. Why is this
?
I then googled and read in
http://www-1.ibm.com/support/docview.wss?rs=994&context=SSSHAD&dc=DB5...
that stl "caches" memory and they gave a work around for it. I tried in
the code. Even that is not working.
Let me tell that valgrind or purify is not showing any leak in the
code. I some how need to free
from stl the memory. Is there any way ? Could any one help me ? I need
a general solution which is applicable for all stl containers. I cannot
wait for the program to terminate as i need to make more allocations
later
|
Design your own, non-caching allocator and make the STL containers use it.
All STL containers provide a hook for that in the second or third template
parameter.
Best
Kai-Uwe Bux |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Nov 22, 2008 8:43 pm | All times are GMT
|
|
Power Rangers | Dutch Bodybuilding Forums | Debt | Mortgage Calculator | Reptile Tank
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|