Q:Detecting at memory leak and pidin/ps/spin

Recently I had to trace down a memory leak in a fairly large application
(using about 38 MB memory). The memory leak was small, but definitely there
(16 KB / min).

When I used pidin or ps to determine how much memory the application used, I
could not see the memory leak until 30 min of running even though the
application was leaking.

My question is two fold - is there at better way to detect memory leak than
using spin/pidin/ps?
and also why would spin/pidin/ps not show any leakage until 30 min later?

Thanks
Jens

I can only answer you to the first question. If you are using IDE for 6.3,
memory analysis tool lets you trace memory leaks together with wrong frees.
The only thing I don’t feel confident is how it works with so huge
applications. Should be thoroughly tested.

Alex

“Jens H Jorgensen” <jhj@remove-nospam-videk.com> wrote in message
news:bd6rb4$ef0$1@inn.qnx.com

Recently I had to trace down a memory leak in a fairly large application
(using about 38 MB memory). The memory leak was small, but definitely
there
(16 KB / min).

When I used pidin or ps to determine how much memory the application used,
I
could not see the memory leak until 30 min of running even though the
application was leaking.

My question is two fold - is there at better way to detect memory leak
than
using spin/pidin/ps?
and also why would spin/pidin/ps not show any leakage until 30 min later?

Thanks
Jens

Jens H Jorgensen <jhj@remove-nospam-videk.com> wrote:

Recently I had to trace down a memory leak in a fairly large application
(using about 38 MB memory). The memory leak was small, but definitely there
(16 KB / min).

When I used pidin or ps to determine how much memory the application used, I
could not see the memory leak until 30 min of running even though the
application was leaking.

My question is two fold - is there at better way to detect memory leak than
using spin/pidin/ps?
and also why would spin/pidin/ps not show any leakage until 30 min later?

Your heap will be pre-grown to a certain size. The malloc() library
will only request more memory from the OS when that is used up. Any
memory that is owned by your process, but “free” according to malloc()
library will still show as part of your process’s memory according
to spin/pidin/ps.

The “better” way to detect the leakage is using the malloc information
view in the IDE – where it will record allocs/frees in different
“bucket” sizes as they occur…and you can see the growing mismatch
of allocations vs frees far more quickly.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Thanks David

I kind came to the conclusion myself that it must have been some earlier
alloc’s which was then free again that cause it to be while before you could
see anything with pidin.

Now regarding IDE - we are emacs/vi and Makefile people so we don’t use the
IDE. Furthermore the project is being supported on QNX 6.1 and dates back to
QNX 6.0, so we are not using or have any intension to use the IDE. How does
the IDE get the detailed memory information and is there a way to get the
same information through the command prompt?

Thanks
Jens


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:bdv020$1mi$1@nntp.qnx.com

Jens H Jorgensen <> jhj@remove-nospam-videk.com> > wrote:
Recently I had to trace down a memory leak in a fairly large application
(using about 38 MB memory). The memory leak was small, but definitely
there
(16 KB / min).

When I used pidin or ps to determine how much memory the application
used, I
could not see the memory leak until 30 min of running even though the
application was leaking.

My question is two fold - is there at better way to detect memory leak
than
using spin/pidin/ps?
and also why would spin/pidin/ps not show any leakage until 30 min
later?

Your heap will be pre-grown to a certain size. The malloc() library
will only request more memory from the OS when that is used up. Any
memory that is owned by your process, but “free” according to malloc()
library will still show as part of your process’s memory according
to spin/pidin/ps.

The “better” way to detect the leakage is using the malloc information
view in the IDE – where it will record allocs/frees in different
“bucket” sizes as they occur…and you can see the growing mismatch
of allocations vs frees far more quickly.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Jens H Jorgensen <jhj@remove-nospam-videk.com> wrote:

Thanks David

I kind came to the conclusion myself that it must have been some earlier
alloc’s which was then free again that cause it to be while before you could
see anything with pidin.

Now regarding IDE - we are emacs/vi and Makefile people so we don’t use the
IDE. Furthermore the project is being supported on QNX 6.1 and dates back to
QNX 6.0, so we are not using or have any intension to use the IDE. How does
the IDE get the detailed memory information and is there a way to get the
same information through the command prompt?

I’m a vi & makefile guy myself.

There’s a different malloc library – malloc_g that is used that
collects statistics – I expect it could be gotten at the command
line in some way.

You might check out the “Heap Analysis: Making Memory Errors
a Thing of the Past” chapter of the Programmer’s Guide, in
particular the “Memory Leaks” section.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.