Monday, August 26, 2002 08:47 AM
As long as the operating system is capable of allocating the requested space, you will not get an error. That space comes from physical memory and virtual memory (swap). To my knowledge, all of the desktop/workstation operating systems commonly in use today (Win95+, Unix (Linux, AIX, Solaris, HP-UX, BSD, IRIX...), MacOS) support virtual memory, so as long as your swap file|partition is set up to support that much memory your application will work. However... as your application uses more memory, the performance of the system will degrade. The degradation depends largely on the application's working set: the data it is working with most of the time. If the working set gets large enough, you wind up thrashing. Most of the time is spent swapping and your system performance degrades quickly towards being useless.
2. This is dependent on how the operating system allocates memory. Some operating systems are designed to ensure that if X memory is requested by an application (such as a Java VM) that the system can fulfill that request immediately. Others make the assumption that applications tend to request more than they need, and only parcel out the memory as it is actually used. (Those are two major strategies, anyway.)
If you run into performance or memory allocation problems, you will have to tune your application. Common strategies include reducing the working set; compacting the data in some fashion (for example using bit fields instead of booleans); and calculating data on-the-fly instead of keeping it in memory.