|
From: Tony Yat-T. C. <to...@as...> - 2004-05-31 11:07:36
|
Hi, Can valgrind be used for runtime memory checking? Basically, I would like valgrind to show the memory usage difference between point A and point B of a program. After some instructions are executed, I would like valgrind to show which memories have been allocated and still not freed. Doing this, I would be able to figure out if I have forgotton to free some memories programatically. Does anyone know if valgrind could do this? If not, any other similar tool around that could do that for me? Thank you very much. Tony Cheung |
|
From: Tony Yat-T. C. <to...@as...> - 2004-05-31 11:19:00
|
Hi,
Let me give an example,
int main() {
char *ptr = NULL;
...
// Checking should start (Point A)
ptr = malloc(5000);
...
// Here (Point B), I would like valgrind to be able to show that 5000
bytes have been allocated between Point A and here.
...
free(ptr); // Memory will be free'd eventually
}
Is this possible?
Thanks a lot.
Tony Cheung
Tony Yat-Tung Cheung wrote:
> Hi,
>
> Can valgrind be used for runtime memory checking?
>
> Basically, I would like valgrind to show the memory usage difference
> between point A and point B of a program. After some instructions are
> executed, I would like valgrind to show which memories have been
> allocated and still not freed. Doing this, I would be able to figure
> out if I have forgotton to free some memories programatically.
>
> Does anyone know if valgrind could do this? If not, any other similar
> tool around that could do that for me?
>
> Thank you very much.
>
> Tony Cheung
>
|
|
From: Nicholas N. <nj...@ca...> - 2004-06-02 20:35:33
|
On Mon, 31 May 2004, Tony Yat-Tung Cheung wrote:
> int main() {
> char *ptr = NULL;
> ...
> // Checking should start (Point A)
> ptr = malloc(5000);
> ...
> // Here (Point B), I would like valgrind to be able to show that 5000
> bytes have been allocated between Point A and here.
> ...
> free(ptr); // Memory will be free'd eventually
> }
>
> Is this possible?
Memcheck and Addrcheck can do leak checking at the end, and in certain
spots if you use the DO_LEAK_CHECK client request. Massif does heap
profiling. But no existing tool does exactly what you want.
N
|