<div>Is this a problem of memory fragmentation?</div> <div> </div> <div>Jim<BR><BR><B><I>Lassi Paavolainen <lopaavol@jyu.fi></I></B> wrote:</div> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi,<BR><BR>I was wondering about a memory allocation problem that seems to be only in <BR>some machines where we run our software so I decided to make a simple test <BR>program for that (code attached at the end of the message).<BR><BR>I got some interesting results from the test program that I cannot <BR>explain. I used same code in console application not using VTK and in VTK <BR>class but got different results of maximum memory possible to dynamically <BR>allocate. Result was also platform dependent in VTK class.<BR><BR>To the results. I used three different systems explained below:<BR><BR>Linux (64 bit): 2 GB of RAM, VTK 5.2, Python 2.5<BR>Windows Vista (32 bit): 3 GB of RAM, VTK 5.2, Python 2.6<BR>Windows XP
Pro (32 bit): 8 GB of RAM (3 GB usable), VTK 5.2, Python 2.6<BR><BR>Exactly same code was used in both Windows machines (compiled in Vista). I <BR>ran this code from command line and using Python interpreter to ran <BR>wrapped VTK class and got following interesting results:<BR><BR>Linux:<BR>- bash: about 3300 MB<BR>- Python: about 3300 MB<BR><BR>Vista:<BR>- Command line: about 1720 MB<BR>- Python: about 1180 MB!!!<BR><BR>XP Pro:<BR>- Command line: about 1920 MB<BR>- Python: about 720 MB!!!<BR><BR>So my question is, how it is possible that VTK class ran from Python in <BR>Windows can't allocate as much continuous memory as it is possible to <BR>simple application? Same thing happens if I try to allocate memory using <BR>for example vtkUnsignedCharArray. I'm guessing the problem is not in VTK <BR>but Python wrapped VTK. Does anyone know where that memory limit defined <BR>by Python wrapped VTK and platform is coming from?<BR><BR>Here is the memory allocation testing code.
Probably not the best but <BR>gives similar results as in real application.<BR><BR>#include <IOSTREAM><BR><BR>#define START_ALLOC 1048576<BR>#define MAX_ALLOC 4294967296<BR>#define START_STEP 536870912<BR><BR>int main(int argc, char* argv[])<BR>{<BR>long long alloc = START_ALLOC;<BR>long long maxAlloc = MAX_ALLOC;<BR>long long minAlloc = 0;<BR>long long step = START_STEP;<BR>while(maxAlloc - minAlloc > START_ALLOC) <BR>{<BR>std::cout << "Allocating " << alloc << " bytes of memory." << std::endl;<BR>try <BR>{<BR>char *mem = new char[alloc];<BR>minAlloc = alloc;<BR>alloc += step;<BR>delete[] mem;<BR>}<BR>catch (std::bad_alloc &ba)<BR>{<BR>std::cout << "Couldn't allocate " << alloc / 1048576 << " MB of memory." << std::endl;<BR>maxAlloc = alloc;<BR>alloc = minAlloc;<BR>step /= 2;<BR>alloc += step;<BR>}<BR>}<BR><BR>std::cout << "Maximum size of memory allocated: " << minAlloc / 1048576 << " MB" <<
std::endl;<BR><BR>return 0;<BR>}<BR><BR>Regards,<BR>Lassi Paavolainen<BR>_______________________________________________<BR>This is the private VTK discussion list.<BR>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers<BR></BLOCKQUOTE><BR><p>