<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='color:#888888'>Daniele,<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#888888'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='color:#888888'>Yeah, I&#8217;m not a Java programmer
so I guess I should not be giving advice, but I happen to remember similar issues
when using gdal from jni in another application I worked on a year or two
ago.&nbsp; Basically, I think the goal is to minimize the memory used by the
JRE and run gdal processes as out-of-process exe programs so they can have as
much memory as needed to perform memory allocations.&nbsp; It&#8217;s either
that or let the JRE consume all the memory&#8230;not recommended&#8230;or get
more memory&#8230;which is always recommended. </span><span style='font-family:
Wingdings;color:#888888'>J</span><span style='font-size:11.0pt;font-family:
"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Best regards,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Martin Chapman<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Chief Software Architect<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Fortified Datacom Inc.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>http://www.fortifieddatacom.com<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>mchapman@fortifieddatacom.com<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>303-324-1065<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Daniele Romagnoli
[mailto:dany.geotools@gmail.com] <br>
<b>Sent:</b> Friday, January 04, 2008 10:26 AM<br>
<b>To:</b> mchapman@texelinc.com; Simone Giannecchini;
gdal-dev@lists.osgeo.org; Frank Warmerdam<br>
<b>Subject:</b> Re: [gdal-dev] In Memory Raster - allocation run out of memory
onbig sizes.<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>Sorry Martin,<br>
I will rectify the statement in my previous reply: &quot;I guess that
increasing the xmx, &quot;steals&quot; memory which could be used by native
items.&quot;<br>
I'm saying that I have noticed this:<br>
when increasing xmx settings, the out of memory errors in the native method
occurs with a smaller requested amount of data with respect to the case of a
lower xmx set.<br>
As an instance,&nbsp; Xmx1024 allows the native method to allocate only &lt;550
MB memory while Xmx16M allows to allocate up to ~820MB. <br>
<br>
Thanks for your help.<br>
<br>
Regards,<br>
Daniele<br>
<br>
<o:p></o:p></p>

<div>

<p class=MsoNormal>On Jan 4, 2008 6:05 PM, Daniele Romagnoli &lt;<a
href="mailto:dany.geotools@gmail.com">dany.geotools@gmail.com</a>&gt; wrote:<o:p></o:p></p>

<p class=MsoNormal>Hi Martin,<br>
I'm using GDAL through JNI (by means of the SWIG's generated java bindings). <br>
However, I guess that increasing the xmx, &quot;steals&quot; memory which could
be used by native items.<br>
<br>
Regards, <br>
<span style='color:#888888'>Daniele.</span><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal>On Jan 4, 2008 5:32 PM, &lt;<a
href="mailto:mchapman@texelinc.com" target="_blank">mchapman@texelinc.com</a>&gt;
wrote: <o:p></o:p></p>

<p class=MsoNormal>Daniele,<br>
<br>
Are you using gdal api through jni or are you calling one of gdals exe
programs? &nbsp;Java limits the total memory for in-process dll's to whatever
the xmx is set to minus whatever the jre needs. &nbsp;I have dealt with this
using java before. &nbsp;You can either increase the xmx setting or call gdal
from outside the java runtime, like a c++ exe. &nbsp;In any case, you will
always be limited to the amount of memory on your machine. <br>
P.S. &nbsp;A good driver will use memory mapped file io (file channels in java
NIO) for reading and writing which gives you a max file size of 1.8 Exobytes on
windows and will consume minimal memory during execution...like a couple of MB.
Unfortunately, most drivers don't use file channels. :) <br>
<br>
Martin<br>
<br>
Sent via BlackBerry by AT&amp;T<o:p></o:p></p>

<div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
-----Original Message-----<br>
From: Frank Warmerdam &lt;<a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a>&gt;<br>
<br>
Date: Fri, 04 Jan 2008 11:09:19<br>
To:Daniele Romagnoli &lt;<a href="mailto:dany.geotools@gmail.com"
target="_blank">dany.geotools@gmail.com</a>&gt;<br>
<a href="mailto:Cc:gdal-dev@lists.osgeo.org" target="_blank">Cc:gdal-dev@lists.osgeo.org
</a><br>
Subject: Re: [gdal-dev] In Memory Raster - allocation run out of memory on <br>
&nbsp; &nbsp; &nbsp; &nbsp;big sizes.<br>
<br>
<br>
Daniele Romagnoli wrote:<br>
&gt; Hi list,<br>
&gt; I'm trying to build a very big In Memory Raster Dataset (~1 GB) using<br>
&gt; SWIG's Java Bindings on my Notebook (with Windows Vista, with 2GB ram) <br>
&gt;<br>
&gt; When calling the java method memoryDriver.create(...) the following<br>
&gt; error appears &quot;ERROR 2: Unable to create band arrays ... out of
memory&quot;<br>
&gt; which is thrown when the underlying calloc method can't successfully <br>
&gt; allocate memory.<br>
&gt; I have performed some tests and tunings with the following conclusions:<br>
&gt; - reducing the JVM Heap Size (using -Xmx command) allows to allocate a<br>
&gt; bigger native memory portion (using -Xmx1024M allows me to allocate only <br>
&gt; &lt;550 MB memory while using -Xmx16M allows me to allocate up to ~820MB)<br>
&gt; [Java Heap space and &quot;Native&quot; Heap space are managed separately]<br>
&gt; - increasing the virtual memory, the result is the same (out of memory). <br>
&gt; - killing all unuseful processes -&gt; freeing more physical memory (~1.2<br>
&gt; GB), the result is the same (out of memory))<br>
&gt; Any setting allows me to allocate a max of ~840000 KBytes.<br>
&gt;<br>
&gt; Anyway, why having almost 1.2 GB free physical memory and a 3GB virtual<br>
&gt; memory setting (with ~2GB free) allows me only to create always ~840000<br>
&gt; KBytes?<br>
&gt; Does anyone know how memory is managed, how the calloc method operates <br>
&gt; and whether an OS limitation exist?<br>
&gt; Thank you very much.<br>
<br>
Daniele,<br>
<br>
I have no reason to believe this is a GDAL specific problem. &nbsp;I presume
you<br>
are running 32bit Windows Vista? &nbsp;If so, I believe any one process can
have <br>
at most 2GB of heap space which in your case would presumably be split<br>
between the JVM and non Java memory in the same process.<br>
<br>
I think you could allocate larger in memory rasters if you were running Win64<br>
which has a very large potential virtual memory size per process.<br>
<br>
PS. I started out this reply to tell you to check the ulimit command output<br>
which reports per-process memory limits on linux before I realized you were <br>
using windows. &nbsp;I don't know if there is any equivelent thing on windows.<br>
<br>
Best regards,<br>
--<br>
---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up &nbsp; | Frank Warmerdam, <a
href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>
light and sound - activate the windows | <a href="http://pobox.com/%7Ewarmerdam"
target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush &nbsp; &nbsp;| President OSGeo, <a
href="http://osgeo.org" target="_blank">http://osgeo.org</a><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org
</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>

</div>

<p class=MsoNormal><br>
<br clear=all>
<o:p></o:p></p>

</div>

</div>

<p class=MsoNormal>-- <br>
------------------------------------------------------- <o:p></o:p></p>

<div>

<div>

<p class=MsoNormal><br>
Eng. Daniele Romagnoli <br>
Software Engineer<br>
<br>
GeoSolutions S.A.S.<br>
Via Carignoni 51<br>
55041 Camaiore (LU)<br>
Italy<br>
<br>
phone: +39 0584983027<br>
fax: &nbsp; &nbsp; +39 0584983027<br>
mob: &nbsp; +39 328 0559267<br>
<br>
<br>
<a href="http://www.geo-solutions.it" target="_blank">http://www.geo-solutions.it</a><br>
<br>
-------------------------------------------------------<o:p></o:p></p>

</div>

</div>

</div>

<p class=MsoNormal><br>
<br clear=all>
<br>
-- <br>
-------------------------------------------------------<br>
Eng. Daniele Romagnoli <br>
Software Engineer<br>
<br>
GeoSolutions S.A.S.<br>
Via Carignoni 51<br>
55041 Camaiore (LU) <br>
Italy<br>
<br>
phone: +39 0584983027<br>
fax: &nbsp; &nbsp; +39 0584983027<br>
mob: &nbsp; +39 328 0559267<br>
<br>
<br>
<a href="http://www.geo-solutions.it">http://www.geo-solutions.it</a><br>
<br>
------------------------------------------------------- <o:p></o:p></p>

</div>

</body>

</html>