By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

C++ Map does not release memory

P: 2
I have created a small map like this.
typedef map<int,string> TEST_MAP;
TEST_MAP testMap;

I add about 10,000 string entries into the map like this

tempStr="test Program";
for(int counter =0;counter<10000;counter++)
testMap[counter]= tempStr;

the size of the memory used by the program increases to some amount after I have added the entries. ( I saw it using top command in linux )

then I added some more entries like this.

for(int counter =10000;counter<20000;counter++)
testMap[counter]= tempStr;

The size of the program again increases to some new value.

But when I delete the entries like the following the program size remains the same. It does not dicreases. I.e the program does not release the memory used by it.

for(int counter =0;counter<20000;counter++)

can any one help ?

Mar 9 '07 #1
Share this Question
Share on Google+
2 Replies

P: 1,806
How do you know memory is not being released? Presumably you are measuring somehow the memory used? Do you know (for example) how much memory is leaking?
Mar 10 '07 #2

P: 2
actually I was using the top utility of linux to see howmuch memory the program consumes.
Oct 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.