title: Dealing with large amounts of data in c++
body: <p>I have an application that sometimes will utilize a large amount of data.  The user has the option to load in a number of files which are used in a graphical display.  If the user selects more data than the OS can handle, the application crashes pretty hard.  On my test system, that number is about the 2 gigs of physical RAM.</p>
  
  <p>What is a good way to handle this situation?  I get the "bad alloc" thrown from new and tried trapping that but I still run into a crash.  I feel as if I'm treading in nasty waters loading this much data but it is a requirement of this application to handle this sort of large data load.</p>
  
  <p>Edit:  I'm testing under a 32 bit Windows system for now but the application will run on various flavors of Windows, Sun and Linux, mostly 64 bit but some 32.</p>
  
  <p>The error handling is not strong:  It simply wraps the main instantiation code with a try catch block, the catch looking for any exception per another peer's complaint of not being able to trap the bad_alloc everytime.</p>
  
  <p>I think you guys are right, I need a memory management system that doesn't load all of this data into the RAM, it just seems like it.</p>
  
  <p>Edit2: Luther said it best.  Thanks guy.  For now, I just need a way to prevent a crash which with proper exception handling should be possible.  But down the road I'll be implementing that acception solution.</p>