MetallicPriest
MetallicPriest

Reputation: 30843

Keeping address space size to 4 GB in 64 bit

I want to keep some applications to run with a 4 GB address space within a 64 bit OS running on a 64 bit processor (x86 xeon, 8 core). I know there is an option to compile with -m32 option, but at this moment the computer I'm working with, doesn't have the required support for compiling with -m32, so I can't use it, neither I can install anything on that computer as I don't have any rights.

Now my question is if there is any possibility to restrict address space to 4 GB. Please don't ask me why I want to do so, just tell me how if that is possible. Thanks.

Upvotes: 1

Views: 701

Answers (2)

thiton
thiton

Reputation: 36059

The ulimit/setrlimit mechanism, accessible in bash via ulimit, can do this with minor drawbacks.

ulimit -v 4000000

should limit the memory available to the current process group to 4 GB.

However, it limits the total size of your address space mappings, and does not limit your mappings' offset - you still may have pointers larger than 2^32.

Upvotes: 3

talonmies
talonmies

Reputation: 72372

You could try using setrlimit to impose a virtual memory limit on the process during its initialization, via the RLIMIT_AS attribute. I have used setrlimit to increase resource allocations to a user space process before, but I don't see why it wouldn't work in the other direction as well.

Upvotes: 3

Related Questions