le 25/06/03 3:12, Richard Coutts � [EMAIL PROTECTED] a �crit�:
> I'm getting an exception from within "new" on ROMs for older handhelds, such
> as the m515, when the number of calls to new exceeds 5000 or so.
>
> It's happening when reading a database. My database represents a drawing
> that has entities, such as lines, circles, etc. When reading a database, I
> make a call to new for each entity in the database. So, if there are 5000
> lines in the database, I make 5000 calls to "new", one for each line, and
> put all of the lines in a graph for rendering.
>
> A database that works fine on a Zire 71 is throwing an exception on an m515.
> Running the database with POSE I'm finding the exception thrown from within
> a call to "new" after 5000 or so entities.
>
> The entities are only taking up 200Kb or so of memory, so there's plenty of
> memory left or the m515. Is it possible that I'm running into some other
> limitation?
>
> Thanks,
> Rich
>
Well the memory available for storage is not fully available for the
application heap. So you're probably running into this limit.
Since the most widely used device is the PalmV with only 2MB, you should
consider very carefully the way you allocate all this data.
Since the data is already in memory (the database IS in memory), maybe you
don't need to allocate a copy of your data. Certainly, your code looks like
the following:
switch(objkind)
{
case 'line':
obj = new lineobj(); // allocates data
break;
case 'circ':
obj = new circleobj();
break;
...
}
obj->InitFromRecord(); // copies data from database
obj->Draw();
You could write something like:
lineobj line;
circleobj circle;
switch(objkind)
{
case 'line':
obj = &line; // no allocation (instance is in the stack)
break;
case 'circ':
obj = &circle;
break;
...
}
obj->UseRecordData(); // refers to data in database (no copy)
obj->Draw();
Since you will avoid both an allocation and an initialization, this code
will probably run faster than your actual code, and will consume very little
memory.
-------------------------------
Eric VERGNAUD - JLynx Software
Cutting-edge technologies and
services for software companies
web: http://www.jlynx.com
-------------------------------
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/