[gradsusr] memory allocation error in gxhpng / printim
P. R.M.
romero619 at hotmail.com
Wed Jan 5 15:38:26 EST 2011
Hi,
this is a message/question for grads developers...
A short while back I saw some messages go by regarding the mysterious 'memory allocation errors' in gxhpng when drawing large shapefiles and using printim.
I ran into this problem yesterday when trying to draw gshhs shapefiles (using the new, built-in 'draw shp' command).
I dug into the source code and did some debugging.
It turns out that the grads metabuffer is based on using short (16-bit) integers.
So, regardless of the amount of memory your system has, the maximum number of polygon vertices that can be stored in the buffer is 32,767.
In my case, the gshhs shapefile I was trying to draw had about 40,000 vertices.
Since this value couldnt be stored in the metabuffer, I was getting a 'junk' negative value for the polygon vertext count, and this was causing the memory allocation to fail.
My quick&dirty workaround was to upgrade the metabuffer's 'short ints' to regular 'gaint' datatypes.
I guess this effectively doubles the memory usage of the metabuffer & grads in general.
However, it solved the problem...
I didnt try converting to 'unsigned short' integers in the metabuffer read/write routines,
but perhaps this could be implemented instead of being forced to use long integers?
pablo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20110105/64529218/attachment-0003.html
More information about the gradsusr
mailing list