68 #include <sys/types.h> 69 #include <sys/sysctl.h> 83 LargeByteBuffer::LargeByteBuffer(
string sPath,
int headerSize)
90 fileSize = FileUtils::getFileSize(sPath);
99 mmPageSize = pageSizeMultiple * (_64_MEGABYTE/osPageSize);
106 double MAX_PORTION_OF_RAM_AVAILABLE = 0.60;
107 int MaxPages = (int)(ramSizeInBytes * MAX_PORTION_OF_RAM_AVAILABLE/mmPageSize);
108 VersatileMemoryPage::setMaxPages(MaxPages);
113 numPages = FullPages + (PartialPageSize == 0 ? 0 : 1);
120 for (
int i = 0; i < numPages; i++)
122 FileOffset mapping_len = min( mmPageSize, sizeRemaining);
124 masterBuffer.push_back(
VersatileMemoryPage(mmPageSize*i, mapping_len, fd, pageManagementList));
126 sizeRemaining -= mapping_len;
136 char* p2D = masterBuffer[Page].get() + loc;
137 int val = ByteUtilities::readInt(p2D);
144 char* p2D = masterBuffer[Page].get() + loc;
145 Long val = ByteUtilities::readLong(p2D);
150 uint64_t LargeByteBuffer::lcm(uint64_t _a, uint64_t _b)
156 uint64_t a = _a, b = _b;
167 uint64_t LargeByteBuffer::getRamSize()
169 #ifdef _SC_PHYS_PAGES 170 long pages = sysconf(_SC_PHYS_PAGES);
171 long page_size = sysconf(_SC_PAGE_SIZE);
172 return pages * page_size;
174 int mib[2] = { CTL_HW, HW_MEMSIZE };
175 u_int namelen =
sizeof(mib) /
sizeof(mib[0]);
177 size_t len =
sizeof(ramSize);
179 if (sysctl(mib, namelen, &ramSize, &len,
NULL, 0) < 0)
181 cerr <<
"Could not obtain system memory size"<<endl;
184 DEBUGCOUT(2) <<
"Memory size : "<<ramSize<<endl;
195 LargeByteBuffer::~LargeByteBuffer()
197 masterBuffer.clear();
198 delete pageManagementList;
static FileOffset mmPageSize
#define SIZE_OF_TRACE_RECORD