--- trunk/src/brains/BlockSnapshotManager.cpp 2005/02/13 19:10:25 324 +++ trunk/src/brains/BlockSnapshotManager.cpp 2005/02/17 15:18:36 358 @@ -40,6 +40,7 @@ */ #include #include "brains/BlockSnapshotManager.hpp" +#include "utils/residentMem.h" #include "utils/physmem.h" #include "utils/Algorithm.hpp" #include "brains/SimInfo.hpp" @@ -48,21 +49,23 @@ BlockSnapshotManager::BlockSnapshotManager(SimInfo* in namespace oopse { BlockSnapshotManager::BlockSnapshotManager(SimInfo* info, const std::string& filename, int storageLayout, int blockCapacity) - : SnapshotManager(storageLayout), info_(info), blockCapacity_(blockCapacity), activeBlocks_(blockCapacity_, -1) { + : SnapshotManager(storageLayout), info_(info), blockCapacity_(blockCapacity), + activeBlocks_(blockCapacity_, -1), activeRefCount_(blockCapacity_, 0) { nAtoms_ = info->getNGlobalAtoms(); nRigidBodies_ = info->getNGlobalRigidBodies(); - double avalPhysMem = physmem_available(); + double physMem = physmem_total(); + double rssMem = residentMem(); + double avaliablePhysMem = physMem - rssMem; int bytesPerStuntDouble = DataStorage::getBytesPerStuntDouble(storageLayout); int bytesPerFrame = (nRigidBodies_ + nAtoms_) * bytesPerStuntDouble; - int frameCapacity = int (avalPhysMem / bytesPerFrame); + int frameCapacity = int (avaliablePhysMem / bytesPerFrame); nSnapshotPerBlock_ = frameCapacity /blockCapacity_ ; - reader_ = new DumpReader(info, filename); nframes_ = reader_->getNFrames(); @@ -72,12 +75,15 @@ BlockSnapshotManager::BlockSnapshotManager(SimInfo* in } for (int i = 0; i < nblocks; ++i) { - blocks_.push_back(SnapshotBlock(i, (i+1)*nSnapshotPerBlock_)); + blocks_.push_back(SnapshotBlock(i*nSnapshotPerBlock_, (i+1)*nSnapshotPerBlock_)); } //the last block may not have nSnapshotPerBlock frames, we need to consider this special situation blocks_.back().second = nframes_; - snapshots_.insert(snapshots_.begin(), nframes_, NULL); + snapshots_.insert(snapshots_.begin(), nframes_, static_cast(NULL)); + + std::cout << "physmem = " << int(physMem) << "\trssMem = "<< int(rssMem) << "\t availablePhysMem = " << int(avaliablePhysMem) <