can I use command "ps" to find memory leak

1 . Thanks for everyone who reads the post first.
2 . I have a idea : whether can I use command "ps" to find which application acquire memory usually .
3 . I do not confirm whether it is correctly , then I do an experiment in Tru64 unix :
I write the simple programe a.c below :

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
char *p;

 while\(1\)
 \{
       p = \(char *\) malloc\(81920\);

       sleep\(1\);
  \}

  return 0;

}

cc -g a.c -o a.out
./a.out

then I type ps uax | grep a.out | grep -v grep every 2 seconds , I find that the RSS and VSZ increments .
4 . So I guess that maybe I can use "ps aux" command to determine whether a programe acquire memory from system usually (I activate ps command periodly using crontab).

You can certainly use ps to see the size of a process as your experiment proved. But if you find a process that is growing, it may or may not have a memory leak. And if you extend your experiment to do malloc() and then free() you will probably find the process will not shrink. Freed memory is returned to the pool of memory available for another malloc, it is not returned to the os. At least that's the way every malloc() library I have seen works.

1 . Thanks and regards to Perderado
2 . By the way , I find that the "ps aux" command not only find the malloc() but also find if I use mmap() and ftruncate() to increment the disk file size .More if I use shmget() continously ,ps also find the RSZ increments .
3 . But now,I have meet a problem :
I use command "dxsysinfo" (Digital unix command to display the disk usage , CPU load,free memory ,free swap) . I find the "free memory" decrease from 54%(a month ago) to 0% (now).Then I type "ps aux" ,I am surprised that all process work correctly , the used memory now is equal to the used memory a month ago ( I use "ps aux" every 30 minutes with crontab)
4 . the question is that :
If an application malloc() first and then free() continously,whether it will cause the problem I introduced above.If it is so , where can I download a memory check tool for Tru64 Unix
5 .thanks

I don't know tru64 nor dxsysinfo but I can answer a few things.

First, about malloc() and free()...if a process malloc's an area then free's it...there is no problem and the process won't grow over time. But the heap area can get fragmented if lots of mallocs and frees happen for many different buffer sizes. If this happens the process may grow over time.

Your shmget() comment means that System V style shared memory may be an issue. It is possible to allocate a System V shared memory segment and then exit without freeing it. The shared memory segment will continue to exit but no process is attached to it. At some point in the future, a process could attach to it if the process had the key. Meanwhile the segment is taking virtual memory at least. And it could have been locked into core. The command "ipcs" can display these. And the command "ipcrm" can remove them.

thanks .

You can try Valgrind to find memory leaks.