Is there any limit on the size of TMapFile?

Dear rooters,

I have the following code to create a shared memory block:

TMapFile::SetMapAddress(0xb46a5000);
TMapFile* mapFile = TMapFile::Create("/tmp/shared.root","recreate", 59090000,"ROOT shared memory");
mapFile->Print();

The first sentence is used based on the instruction in:
root.cern.ch/root/html/TMapFile. … MapAddress
Though the function is used to “Set preferred map address”, I cannot ignore it. Without using it, I get seg fault. Is it a must-have?

The value 59090000 in the second sentence specify the size of the shared memory. According to the output of the third sentence, 56.36 M shared memory is created in my machine. If I specify any value bigger than that, I get seg. fault. Is there an up-limit on the size of TMapFile?

Cheers, Jing

Hi, as at the low level mmap() with the option MAP_FIXED is called it might be failing if their is not more than 59MB free at that location. This situation is far from ideal at the moment, but I’ve no time to fix it at the moment, sorry.

Cheers, Fons.

Dear Fons,

I see. Thank you for sharing this information.

Cheers, Jing

Dear Fons,

if I change the starting address several times, I may succeed allocating enough memory. However, I have to open a ROOT interactive session every time when I want to get a new address. Is it possible to do it in my source code? Say, something like:

TMapFile::SetMapAddress(0xa619e000);
TMapFile* mapFile = TMapFile::Create("shared.root","recreate",299090000,"ROOT shared memory");
while(1) {
   Int_t size = mapFile->GetAllocatedSize();
   if (size<someValue) {
       TMapFile::SetMapAddress(someNewAdress);
       mapFile = TMapFile::ReCreate(....);
   } else 
      break;
}

Cheers, Jing