Denis wrote: >Folks, > >I am not certain if this has anything to do with Gentoo or not. I am >programming something in C, and I need to address as much memory as >possible for the arrays that need to be specified as global variables. > I have 2 GB memory on this machine, and I'd like to use as much of it >as possible, but my code segfaults if I try to allocate more than >around 1 GB of RAM to my running code like that. I heard that this is >due to the dynamic libraries. If I compile with gcc and use the > >
Hi Denis, I know I'm not answering your question directly, but would *strongly* suggest going the dynamic route. The reason is that you are going to want to leave some memory spare for other processes and the kernel to use, or the first time you actually run out of memory, _your_ application is going to be killed by the kernel. It kills the largest memory user first, and it doesn't really matter whether that was stack space or heap space. Your best chance of avoiding the out-of-memory killer is to detect how much spare memory is available at application start, and then allocate 90-95% of that. That assumes of course that you have a high-degree of control over the system and that you don't have to worry about something started by a cron job wanting 200MB of memory. -Richard -- gentoo-user@gentoo.org mailing list