Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jun 2010 12:49:12 +0530
From:      dhruva <dhruvakm@gmail.com>
To:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   mallinfo equivalent on FreeBSD
Message-ID:  <AANLkTimrqHm9_nHLCy0xRpf_h3kIttPHi746gkTKI2Re@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hello,
 I would like to know the memory usage (total virtual memory) inside a
process and make decisions accordingly.
To be more specific, I am using BerkeleyDB backed set or std::set (C++
STL) depending on my current memory usage
as my process will need to run in a resource constrained environment.
By the way, this is user mode application.

Some things I am considering/tried:
1. GNU/Linux has mallinfo and I had my code working based on the
information I get from the call.
2. I tried using getrusage() and it does not give the total virtual
memory usage.
3. Another approach is to set the memory soft limit to the watermark I
am interested, trap SIGSEGV
and increase the watermark to the original value (save it before
modifying). The problem here would be
to differentiate between different causes for SIGSEGV and handling
them differently. In M$ (Windoze), I
could have done this using structured exception handling around the
call to malloc.

The problem in #3 would be to revert once the memory usage has gone
below the watermark.

Any suggestions would help me progress.

with best regards,
dhruva



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimrqHm9_nHLCy0xRpf_h3kIttPHi746gkTKI2Re>