You doubt it. If you need the memory resources used by the gcc or g++ at compile time, you can measure them using gcc -ftime-report (which report both the time and memory of the various GCC phases). You can reduce the resources the compiler consumes to compile using the complex GCC program arguments (describe in detail in the GCC documentation) or reduce the memory limits with the built-in ulimit bash , which interacts with setrlimit (2) syscall. Like others, you can also limit the available memory for running your program using the same ulimit and syscall built-in commands.
But you probably care about the memory resources consumed by your program. I suggest you compile g++ -Wall -g and first learn how to use valgrind (and gdb ) to debug memory leaks. You can even override malloc and free .
Alternatively, you can use the Boehm conservative garbage collector . Then you would use GC_malloc instead of malloc (or use new(gc) instead of new ) and you would no longer like free or delete . But it is a conservative garbage collector (and may leave some memory leaks when you're out of luck).
To better understand the address space used by some process, use the proc (5) file system, specifically /proc/1234/maps for the process map 1234 or /proc/self/maps for the map of your own process. (Run cat /proc/self/maps on the terminal to see the memory card of this cat ). There is also the pmap command.
source share