I have been given responsibility of a complex C++ multi threaded
application which has been developed over many years and with just as
many people involved over that time. These experts have moved on and
my knowledge and expertise of this application is very limited.

Unfortunately, this application has crashed during normal operation.
The application
has had previous crashes but these have been months apart. The core
file generated is
about 490M bytes. I am told this is a symptom of the application
running out of virtual memory - due to memory leak. Solving the
memory leak will be difficult but will be attempted.

I would like a short to medium solution which would entail
monitoring the process image size and warning the user that the image
size is approaching its maximum and that the process will crash ...
and restart. I don't know whether it is the virtual memory space
to the process that is exhausted or the ram space.

I could use the ps command to acquire the process's virtual memory
( SZ field ) and physical memory ( RSS field) usage.

Can you tell me where the maximum virtual and physical memory a
can use is defined ?

Is my approach to this problem correct or is there a better
approach for early detection.

Many thanks for your help.


Platform Information
Machine hardware: sun4u
OS version: 5.8
Processor type: sparc
Hardware: SUNW,Ultra-4