Dynamic Memory Allocation Limit?

Edward Ruggeri smallhand at crawblog.com
Wed Apr 30 00:37:13 UTC 2008


I have recently been writing an implementation of the sieve of
Eratosthenes in C.  To find all primes less than N, I dynamically
create an array of chars (relatively small datatype) of length N+1 (I
know I don't need to represent evens).

Everything works great up until around 600 million, at which case
memory allocation fails.  At this point, I am asking for 600M chars,
which is about 572MB (I might be failing to take account of offset?).

My system has about 2GB of memory.  Top says: Mem: 159M Active, 1113M
Inact, 185M Wired, 56M Cache, 112M Buf, 481M Free.

>From the man page, I am not completely clear what these values mean.
However, I have read elsewhere that memory labeled as inactive should
be available for the heap

Is there a limit to how much memory may be allocated to a process?
Any other reasons someone might think of?

I am using FreeBSD 6.3-prerelease, with SMP for a Athlon X2 4200+ (if
it makes a difference).  Sorry if this is a RTFM question ...

Sincerely,

-- Ned Ruggeri


More information about the freebsd-questions mailing list