[net.unix] Maximum amount of allocatable Virtual memory

template@megatek.UUCP (Template) (04/03/86)

Here's a problem I have recently run into. I'll appreciate it if anyone over
the net can tell me solutions to it:

	I am writing a CPU driver for our new product. Our application requires
a large amount of virtual memory. Since the application is speed critical, I
would like to allocate as much memory as I can get away with initially instead
of allocating on the fly. Does anyone know of how to figure out the MAXIMUM
amount of virtual memory that can be allocated on ANY Unix machine? (My
application needs to run on a variety of UNIX machines).


	Derek Lai		(619) 455-5590 x2034
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121
	sdcsvax!celerity!
	  akgoa!celerity!megatek!template
	    seismo!s3sun!
-- 
	Derek Lai		(619) 455-5590 x2034
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121
	sdcsvax!celerity!
	  akgoa!celerity!megatek!template
	    seismo!s3sun!

tupper@wanginst.UUCP (John Tupper) (04/06/86)

>. . . Does anyone know of how to figure out the MAXIMUM
>amount of virtual memory that can be allocated on ANY Unix machine?

From my experience with 4.1 & 4.2bsd:

The only sure fire way that I would know of is to allocate until an allocation
fails (use a variation of the binary search to cut the number of allocates).

There is a problem with allocating everything you can get your hands on however.
Bsd will only allocate virtual memory if there is room in a swapping
partition to hold the allocated memory. Thus, allocating all the virtual
memory you can will fill the swapping partitions and seriously affect system
performance. It would be impossible to run two copies of your program at once.

Probably a better solution would be:
	1) Allocate on the fly, but allocate in big chunks to reduce to
	   number of allocates
	2) Let the user specify the initial amount of memory to be used
	   (possibly via an environment variable).
-- 
John Tupper                              tupper@wanginst        (Csnet)
Wang Institute of Graduate Studies       wanginst!tupper        (UUCP)
Tyng Road, Tyngsboro, MA 01879           (617) 649-9731