I’m writing an application that performs complex computations on biomolecules. The application needs to read a number of different structures (= molecules) from disk and then perform the necessary calculations.  These molecules are held in a stl vector, for example:

std::vector <CMolecule> m_vMolecules;

 

This works fine as long as the vector doesn’t exceed the RAM memory. Unfortunately, this is not the general case because the number of molecules to be read is typically higher than 20,000 and so, when the RAM memory is not enough, the application’s efficiency decreases dramatically. Perhaps I could try to read only the molecules that don’t go above the memory and when the rest of the molecules are needed, release the first chunk and read a new one. Is this a good approach? If so, any help on the best way to implement this scheme?

If you're not going to be cross-platfrom, then why not use Win32 specific stuff, like memory mapped files, and maybe VirtualAlloc( ) and friends?  Also, how big is each molecule structure in memory?  A simple calc shows that if you've got 256MB of RAM, and each molecule structure is 10KB, you could easily fit them in RAM all at once.

 

Also, off the top of my head, std::deque stores its content in multiple "buckets", so if you add an element for which there's not enough space in the deque, a reallocation of the entire contents would not be necessary.  Of course, you should check it out yourself, because my memory might not be right.


Every deep thinker is more afraid of being understood than of being misunderstood. The latter perhaps wounds his vanity, but the former wounds his heart, his sympathy, which always says: "Ah, why would you also have as hard a time of it as I have?"
-Beyond Good And Evil, F. W. Nietzsche
_______________________________________________
msvc mailing list
[EMAIL PROTECTED]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription 
changes, and list archive.

Reply via email to