Menu

Limit RAM usage while compiling

Help
Sharkey
2023-11-29
2023-12-02
  • Sharkey

    Sharkey - 2023-11-29

    Hello, I recently bought a chromebook that has very limited resources but I would like to use it to compile projects for the Gameboy. SDCC/LCC seems to crash due to lack of RAM and I don't have a lot of storage space for swap. Is there a way to limit the amount of RAM used when compiling? Like a flag I can add to the makefile? I don't mind if it takes longer for the project to compile, I just don't want it to keep crashing. Thanks!

     
    • Philipp Klaus Krause

      RAM usage depends on the --max-allocs-per-node argument. The default is 3000, which should not be a problem. But many people use far higher values (resulting in far higher RAM usage and compile times, and better optimization).

       
    • Benedikt Freisen

      If you are writing new code, i.e. can shape it however you like, working with a larger number of smaller files and keeping functions reasonably small can help reduce RAM usage within the compiler.
      If you use a lot of macros, switching off macro expansion in the preprocessor's diagnostic messages can also help, because the underlying internal data structures in the preprocessor can get quite big. This is actually not SDCC-specific, but affects everything that uses the GNU preprocessor.
      You could try preprocess your source code first and to compile the preprocessed code later. That way you can find out which step uses too much RAM in your case.

       

Log in to post a comment.