[PLUG] Getting the amount of free memory in C

Steve Bonds 1s7k8uhcd001 at sneakemail.com
Thu Nov 7 22:04:14 UTC 2002


On Thu, 7 Nov 2002, Mike Witt mike-at-computer-arts.net |PDX Linux| wrote:

> Fair enough. I guess I'll have to 'fess up to the real reason. I'm
> trying to find a quick way to find out how much memory a fairly
> complex piece of code (that I inherited) is allocating between two
> operations (approximately)  Actually, what I'd like is a variable that
> tells me how much memory my process has allocated. I was just going to
> look at the amount of memory "left" because I *thought* there was an
> easy way to do that. I can arrange for the rest of the system to be
> fairly quiet while I run the test.
> 
> How about a call to tell me how much I've allocated?

You can always grab it via the /proc interface-- even through an external
progam should you like.

Look at "man proc" for the /proc/[pid]/stat entry.  I think that vsize is
the field you want.

  -- Steve






More information about the PLUG mailing list