koolhazz / gperftools

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

virtual memroy grows wildly when I new a bigger block #544

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. new 1gb memory and free it
2. new 1gb + 1kb memory and free it
3. new 1gb + 2kb memory and free it
4. ...

What is the expected output? What do you see instead?
I expected tcmalloc will release the virtual memory. High virtual memory 
sometime will cause new fail

What version of the product are you using? On what operating system?
I make a server, need to reload big files frequently. Each time I new a new 
memory block, load the files to memory, release the older one for lockfree. 

On RHEL4 

Please provide any additional information below.
example code as follows:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <new>

const int _1GB = 1 * 1024 * 1024 * 1024;
const int _1MB = 1 * 1024 * 1024;
int main()
{
    int i = 0;
    while(1) {
        char *p = new (std::nothrow) char[_1GB + i * 1024];                                                                            
        if (p == NULL) {
            printf("new fail\n");
            break;
        }   
        printf("no:%d\n", i); 
        ++i;
        usleep(10000);
        delete []p;
    }   
    return 0;
}

Original issue reported on code.google.com by Yea...@gmail.com on 5 Jul 2013 at 3:56

GoogleCodeExporter commented 9 years ago
This looks like duplicate of issue-368. Please, re-test with latest trunk

Original comment by alkondratenko on 6 Jul 2013 at 8:08

GoogleCodeExporter commented 9 years ago
I re-test with latest trunk, it does not increase again.

I read about the issue-368, the same problem. Thank you very much ;)

Original comment by Yea...@gmail.com on 8 Jul 2013 at 2:15

GoogleCodeExporter commented 9 years ago

Original comment by alkondratenko on 13 Jul 2013 at 10:40