evilsong / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Delete not releasing memory for reuse #492

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I am trying to integrate tcmalloc into my program and faced a issue of memory 
not being reused

1. Converted the tcmalloc.sln to x64 in vs2010 and compiled. 
2. Wrote a simple test program in x64 on windows 7 x64 with visual studio 2010
3. Gist of the program is creating a struct multiple times and deleting it and 
recreating it again. pesudo code is listed

struct A
{
   int data1;
   double data2;
   long data3;
};
count = 3000000;
vector v;

for(int i=0; i<count; i++)
{
  A a = new A();
  v.add(a);
}

subsequently I will delete every content of the vector, then insert again and 
so on.

This code works perfectly fine and memory didn't go up after the first round of 
insertion and deletion proving that memory is reused. So i did a second test I 
changed struct A to a larger size to test. 
struct A
{
   int data1;
   double data2;
   long data3;
   char data4[32000];
};
count = 120000;

When I run the program it does not reuse all the memory after I deleted the 
data resulting in memory usage going up till about 2GB before stablising at 2GB 
without going up again.

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by tqx...@gmail.com on 14 Jan 2013 at 2:06

GoogleCodeExporter commented 9 years ago
Have you tried turning on the heap leak checker or the heap profiler?

Original comment by chapp...@gmail.com on 11 Mar 2013 at 12:50

GoogleCodeExporter commented 9 years ago
This actually sounds like a duplicate of:

http://code.google.com/p/gperftools/issues/detail?id=489

Can you try calling MallocExtension::instance()->ReleaseFreeMemory() and 
MallocExtension::instance()->ReleaseToSystem(LONG_MAX) in your program and see 
what effect it has?

Original comment by chapp...@gmail.com on 11 Mar 2013 at 12:58

GoogleCodeExporter commented 9 years ago
Yes. Windows doesn't have functional "return memory back to os" support yet. 
issue 489 tracks this

Original comment by alkondratenko on 14 Jul 2013 at 3:06