Good afternoon, We are building a prototype deduper for Centos Linux Release x86_32 and Microsoft Windows. One part of the prototype is a MemoryMappedFile program which uses a 1800 element cache. For Centos Linux 5.5 we call msync to synchronize the file with the memory map. For the last several weeks, msync has been functioning okay. Today, msync and perror("msync") are returning "Cannot allocate memory". Why is Centos Linux Version 5.5 x86_32 msync returning "Cannot Allocate memory"? Is it possible for use to fix the "Cannot Allocate memory" error on Centos Linux 5.5 x86_32. Thank you. An excerpt of the memory mapped file program code is shown below:
typedef std::multimap<char *,Range>::const_iterator I;
std::pair<I,I> b = mmultimap.equal_range(TmpPrevMapPtr);
for (I i=b.first; i != b.second; ++i){
std::deque<Range>::iterator iter;
iter = std::lower_bound(ranges_type.begin(),ranges_type.end(),i->second);
if (iter != ranges_type.end() && !(i->second < *iter)){
sz1 = ranges_type.size();
ranges_type.erase(iter);
sz2 = ranges_type.size();
}
}
erasecount = mmultimap.erase(TmpPrevMapPtr);
#if defined(__windows)
retval = FlushViewOfFile(TmpPrevMapPtr, mappedlength);
retval = UnmapViewOfFile(TmpPrevMapPtr);
#elif defined(__unix)
retval = msync(TmpPrevMapPtr, mappedlength, MS_SYNC);
if (retval == -1){
perror("msync");
}
retval = munmap(TmpPrevMapPtr, mappedlength);
if (retval == -1){
perror("munmap");
throw cException(ERR_MEMORYMAPPING,TempFileName);
}
#endif