LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Have GCC use SWAP instead of/with RAM (https://www.linuxquestions.org/questions/linux-software-2/have-gcc-use-swap-instead-of-with-ram-891390/)

Jeff91 07-12-2011 10:02 PM

Have GCC use SWAP instead of/with RAM
 
I'm trying to build firefox mobile (fennec) on a device that only has 256meg of RAM and it is failing out due to lack of RAM errors.

Is there a way I can force the GCC compiler to use SWAP space when compiling instead of RAM? I've got a fairly large swap file.

~Jeff

syg00 07-12-2011 10:29 PM

You cannot get stuff into swap without it being allocated in memory (RAM) and being evicted.
Check you don't have other users of RAM - /tmp for example. Make sure it isn't on a tmpfs (/dev/shm you can't do anything about).

Tinkster 07-13-2011 01:16 AM

Alternatively consider cross-compiling on your big-rig.

flyxtop 06-15-2017 12:42 AM

how to set gcc to use swap file?
 
I have the same problem now. (I'm including a huge file)
We know the swap space is used when the memory runs short while running.
but somehow gcc doesn't seems to use swap space when memory runs low.
(I can see it using free -m command while gcc is running, the used memory goes up and then gives me this
- virtual memory exhausted: Cannot allocate memory during.. error. The swap usage is 0 in the mean time..)
The original question is about how we make gcc use swap file. Does anyone have answer?
Chan

sundialsvcs 06-20-2017 02:01 PM

The gcc compiler is exactly like any other application program: it runs in virtual memory, as dictated by the Linux operating system. It therefore seems that Linux is running out of capacity to run the compiler on that board.

However, the usual practice is not to do that. As others have said, you "cross-compile" on a larger machine, then transfer the binary to the phone or what-have-you. Mobile devices ordinarily do not have sufficient resources to run their compilers directly ... and, you don't need to. The compiler, running on a host machine, generates object-code for the target that must run on the target. (And/Or in a simulator.)

jefro 06-20-2017 04:12 PM

If you are close to amount you might get by with zram and swappiness set to 100.
Strip down your system to the bare amount of current OS needed to compile.
Maybe set ulimit.
Suppose an ultra fast ssd could possibly help timings for swap issues.

Change how the compiler is doing work.

Without changing how a program works it is usually hard to change how ram is used. Ram is ram as they say.

Laserbeak 06-20-2017 04:41 PM

The computer will use the swap space when all the RAM is taken up. I don't think there's any way to specify that any specific program uses swap instead of RAM.

sundialsvcs 06-20-2017 05:03 PM

I suspect that this box simply does not have the resources needed, swap or no swap, and it appears to be exhausting the swap space that it has. The box simply isn't big enough to do the job ... but, it doesn't have to.


All times are GMT -5. The time now is 05:17 AM.