Determining system memory

D.JONES dean at homxb.UUCP
Sat Apr 2 04:35:55 AEST 1988


In article <1271 at PT.CS.CMU.EDU>, edw at IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>  > I have been trying to find a nice, clean way to determine system
>  > memory under SYS V 2.2.  I have come up with two solutions to this
>  > problem.  However, there must be a cleaner/faster way :-).
>  > Any other solutions are welcome (especially those that are faster :-)
> If what you are really interested in is the memory currently available
> to a given process I suggest using sbrk.  sbrk memory
> in fix block sizes until sbrk fails.
> Eddie Wyatt 				e-mail: edw at ius1.cs.cmu.edu

	Now you know how much memory you have for the current process, but
do you have to sbrk() it back if you are going to use malloc() ???  A call
to ulimit() on SysV 2.2 with an arg of 3 will return the max brk value for
the current process.  What about something <simple> like:

long memavail()
{
	return(ulimit(3) - (long)sbrk(0))
}

	It looks like this will work on our SunOS 4.0 machines also. I'm
Just starting to get into this UNIX stuff,   don't flame me if this is a
bozo idea...

					Dean S Jones
					AT&T Gateways!homxb!dean



More information about the Comp.unix.questions mailing list