[Gdal-dev] Windows CE - GDALDatasetRasterIO error

jetelus at centrum.cz jetelus at centrum.cz
Mon Nov 5 08:12:48 EST 2007


>jetelus at centrum.cz schrieb:
>>> jetelus at centrum.cz wrote:
>>>     
>>>>>> Hi, I open and display raster without problems but when I
>>>>>> try zooming I get CE_Failure from GDALDatasetRasterIO with
>>>>>> this error message using GDAL 1.4.2:
>>>>>>
>>>>>> "Assertion `nLockCount == 0' failed in file `..\..\..\gcore
>>>>>> \gdalrasterblock.cpp', line 219"
>>>>>> (and app crashs)
>>>>>>
>>>>>> and this error message using GDAL 1.4.3:
>>>>>>
>>>>>> "Out of memory allocating 59765 byte raster cache block."
>>>>>> (its little better becasuse app doesnt crash)
>>>>>>
>>>>>> RASTER INFO:
>>>>>> bpp: 1
>>>>>> compression: LZW
>>>>>> resolution: 11953 x 10268.
>>>>>> file size: 658kB
>>>>>>
>>>>>> When I convert this raster to 4 bits per pixel everything
>>>>>> is ok and I get no errors but raster file size grows to
>>>>>> 1.7MB. Any ideas? Thx.
>>>>>>           
>>>>> I don't know what device you have but you're trying to open ~120 MB
>>>>> raster in one shot, on mobile device.
>>>>> The error message is clear to me, you're dealing without of memory issue.
>>>>>
>>>>> IMHO, it's not a good idea to feed mobile device with images of that
>>>>> big. Better tile them into smaller pieces, use zoom levels, etc.
>>>>> GDAL for Windows CE gives you with tools to solve this problem.
>>>>>
>>>>> Keep in mind that "GDAL for Windows CE" does not mean you can use all
>>>>> GDAL features on a mobile device the same way as on normal workstation.
>>>>> There are obvious hardware limitations you can not overcome.
>>>>>
>>>>> Cheers
>>>>> --
>>>>> Mateusz Loskot
>>>>> http://mateusz.loskot.net
>>>>>
>>>>>         
>>>> Thank you, I understand but why it works with 4 bpp version of same raster
>>>> which is even bigger?
>>>>       
>>> You wrote that you don't get any errors, but does it mean you can load it
>>> and display?
>>>
>>> Perhaps there is a bug, we can not exclude this option :-)
>>> If you want, you can send me your image file and piece of code presenting
>>> what are you doing exactly, then I will be able to investigate the problem.
>>>
>>> Cheers
>>> -- 
>>> Mateusz Loskot
>>> http://mateusz.loskot.net
>>>
>>>     
>>
>> Yes, I can load and display image. I get this error only when zooming.
>> (and no errors at all for 4bpp version)
>>
>> I have this code:
>> (Windows Mobile 2003 Second Edition)
>>
>>  --------------------------------------------------------------------------------
>>  ...
>>  int panBandMap[1];
>>  panBandMap[0] = 1;
>>
>>  unsigned char* pData = (unsigned char*) malloc(nBufXSize * nBufYSize);
>>
>>  if (!pData)
>>  {
>> 	CString msg("Not enough memory.");
>> 	TRACE(msg);
>> 	MessageBox(NULL,msg,NULL,0);
>> 	return false;
>>  }
>>
>>  CPLErr e=GDALDatasetRasterIO(HDataset, GF_Read, nXOff, nYOff, nXSize, nYSize,
>>         pData, nBufXSize, nBufYSize, GDT_Byte, 1, panBandMap, 1, nBufXSize, 1);
>>
>>  if (e != CE_None)
>>  {
>>         free(pData);
>> 	CString msg(CPLGetLastErrorMsg());
>> 	TRACE(msg);
>> 	MessageBox(NULL,msg,NULL,0);
>>         return false;
>>  }
>>  ...
>>  show loaded raster
>>  ...
>>  free(pData);
>>  --------------------------------------------------------------------------------
>>
>> works for whole image:
>>
>> nXOff = 0
>> nYOff = 0
>> nXSize = 11953
>> nYSize = 10268
>> nBufXSize = 224
>> nBufYSize = 192
>>
>> gives "Out of memory allocating 59765 byte raster cache block." for
>> raster part (same for similar areas when zooming):
>>
>> nXOff = 3011
>> nYOff = 1571
>> nXSize = 7115
>> nYSize = 6561
>> nBufXSize = 248
>> nBufYSize = 228
>>
>> Image is here (450kB):
>>
>> http://rapidshare.com/files/67552472/tif_lzw.rar.html
>>
>> Thx for your time.
>>
>> _______________________________________________
>> Gdal-dev mailing list
>> Gdal-dev at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/gdal-dev
>>
>>   
>Hi,
>
>I tryed your image out with my code and was surprised that my code can
>handle that large images ;) - so just a question: Are there overviews in
>the image?
>
>With my code I was able to pan and zoom around - but after about 8
>actions (I do not know exactly what the problem is - well, I will look
>after it) I get the same error with the same amount of memory:
>Return: 3
>Last Error: Out of memory allocating 59765 byte raster cache block./
>
>This error occured one time after I zoomed in (with about factor 2) and
>another time when I zoomed out (about factor 0.4) -but not all the time.
>I was also abtle to zoom deep in and out.
>With only panning I get this error not that fast I think.
>
>I don't know if this helps- but I try to test some more tonight.
>
>Bye,
>Tom
>

Hi,
thx for testing the image. I tryed to zoom to very small areas and it works.
So I added check for free memory before and after GDALDatasetRasterIO call
and discovered there is 11 MB difference. This is probably reason why all
following operations with larger areas are out of memory.




More information about the Gdal-dev mailing list