Is malloc allocating memory on the virtual memory space ?

John Love-Jensen eljay@adobe.com
Thu Sep 6 13:23:00 GMT 2007


Hi Cesar,

> Is there a way in C to allocate on VM only so the process address space (1G)
> is not touched (or barely touched). Thanks a lot for your help

For both platforms -- Windows NT (3.1, 3.5, 4.0, 2000, XP, Vista) and HP-UX
11 -- VM usage is automatic.

You can make it explicit using memory mapped files.

But that won't address your problem.

The problem is that you are allocating more space than is accessible in a
32-bit address space.

You either need 64-bit address space, or you need to partition your problem
so that only a portion is in memory and the bulk of the data resides in
files.

Imagine, for example, that of your 656000 rows (each of which contains a
columnar string of 141 elements), only 2 can be loaded in memory
concurrently.  Load 'em up, change them & mark that string as dirty, write
the dirty strings back to the working data file (temporary or persistent, as
per your needs).

HTH,
--Eljay



More information about the Gcc-help mailing list