memory leak

I have one programme in PHAB,when it starts,the memory occupy rate is 13%,in the programme there’s on function just like below
{
ptr=new …;

delete [] ptr;
}

when it runs,the memory occupy rate is up to 15%,it’s strange even if I run it 100 times, the memory occupy rate is still 15%,I want to know where the 2% memory lost? by the way if I kill the programme and run it again,the memory occupy rate holds the last value.

You should talk about kbytes instead of %, 2 pourcent of 1gig is very bad, but 2% of 32M is negligable.

You can use the malloc_g library to trace all the memory allocation you program does.

When you allocated memory the head may have to grow,if it does, it doesn’t grow by the amount of ram you requested by rather by bigger block ( don’t know the value) that maybe what you are seeing.

mario,Can one process release all memory that another process allocates?indeed,process B is start by process A,process A knows the pid of process B,sometimes process A want to kill process B,but it can release the memory of B.

When a process terminates all its memory is released (aside shared memory that may not have been unmapped). A process cannot (and should not IMHO) be able to release memory of another process. Unless of course a process provides some custom interface to allow for that.

mario,I never use malloc_g library before,Could you give me a example?another question,what can result to memory grow except using malloc to allocate memory?in my programme,I’m sure that I have free the memory allocated(in c++,it’s new and delete).

in phab,Does using any widget cause memory grow?

There is a chapter on using malloc_g library in the doc. I never used it myself.