473,507 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ Map does not release memory

2 New Member
Hi,
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++)
{
testMap.erase(counter);
}


can any one help ?

Sincerely,
Himanshu.
Mar 9 '07 #1
2 2920
DeMan
1,806 Top Contributor
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
himanshubahl
2 New Member
actually I was using the top utility of linux to see howmuch memory the program consumes.
Oct 4 '07 #3

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

Similar topics

3
4421
by: WinstonSmith | last post by:
Hello everyone, I got a problem about GC when creating large fields (some MB), set reference to null and call GC.Collect. Not all virtual mem is released. Situation improved in .net 1.1 but not...
0
1347
by: gchandran | last post by:
Hi All, Problem: Call to DOMDocument::getElementsByTagName() in a loop causes growth in memory consumption? Consider the following lines of code which simulates the problem that I am facing....
3
3319
by: Marc | last post by:
I am using Visual Studio 2003 with .NET Framework 1.x on XP SP2. I am executing the following code (see also http://dturini.blogspot.com/2004/06/on-past-few-days-im-dealing-with-som e.html) ...
9
8545
by: Frank Rizzo | last post by:
I understand the basic premise: when the object is out of scope or has been set to null (given that there are no funky finalizers), executing GC.Collect will clean up your resources. So I have...
10
1566
by: babak | last post by:
Hi everybody I'm working with a project in embedded Visual Studio 4 and I have a general problem which I hope that somebody can help me with. My problem is the following: My project works fine in...
2
2358
by: Epetruk | last post by:
Hello, I have a problem where an application I am working on throws an OutOfMemoryException when I run it in Release mode, whereas it doesn't do this when I am running in Debug. The...
71
10671
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
19
4167
by: Angus | last post by:
I have a socket class CTestClientSocket which I am using to simulate load testing. I create multiple instances of the client like this: for (int i = 0; i < 5; i++) { CTestClientSocket* pTemp...
4
4095
by: Hong Chen | last post by:
I developed a large program and found the program does not really release memory after the delete operation is taken, since, according to "performance monitor", the virtual bytes used by this...
7
2803
by: Dmitriy V'jukov | last post by:
On Jun 16, 3:09 pm, Anthony Williams <anthony....@gmail.comwrote: Yes, I've already read this. It's just GREAT! It's far more useful and intuitive. And it contains clear and simple binding...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.