Today, during my computer sciene classes I was told that I can adjust the amount of memory my program can allocate during its compilation (using GCC, Linux). This amount is by default set to optimal mode (which means as much as possible).
I could greatly benefit from this compiler feature during debugging my application since I need to properly deal with allocation errors, which is quite tricky on my PC with over 16 GB of RAM.
Does anyone know what this option is? I expect sth like gcc --maxalloc 1024
which would mean that my program will be able to allocate at most 1024 bytes of memory.
I don't know of a compiler option for this. However, the ulimit
Linux command can be used to limit the amount of memory a process can use.
For example, the following command would limit the data segment size of applications run from the current shell:
ulimit -d 1024K
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With