Re: Too many calls to new?

2003-06-25 Thread Ben Combee
At 09:15 PM 6/24/2003, Richard Coutts wrote:
 I believe that the m515 only has 256K of dynamic memory available to the
 device.  Your global memory and your stack space is included in that
value,
 so 200K may very well be the limit.
Ah.  Just so I'm clear on this -- the database resides in storage space, but
since I'm loading every value of the database into a graph, then I'm
effectively creating a copy of the database in dynamic memory, which is very
limited in size on some devices?
Is dynamic memory faster than storage memory?
For reading, dynamic and storage memory is equivalent.  For writing, memory 
on the dynamic heap can be written much quicker, as you don't have to go 
through pointer validation and memory protection.

--
Ben Combee [EMAIL PROTECTED]
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com 

--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Too many calls to new?

2003-06-24 Thread Richard Coutts
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


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Too many calls to new?

2003-06-24 Thread Eric VERGNAUD
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/


Re: Too many calls to new?

2003-06-24 Thread Brad Figler
I believe that the m515 only has 256K of dynamic memory available to the
device.  Your global memory and your stack space is included in that value,
so 200K may very well be the limit.

Brad

Richard Coutts [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 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






-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Too many calls to new?

2003-06-24 Thread Richard Coutts
 I believe that the m515 only has 256K of dynamic memory available to the
 device.  Your global memory and your stack space is included in that
value,
 so 200K may very well be the limit.

Ah.  Just so I'm clear on this -- the database resides in storage space, but
since I'm loading every value of the database into a graph, then I'm
effectively creating a copy of the database in dynamic memory, which is very
limited in size on some devices?

Is dynamic memory faster than storage memory?

Thanks,
Rich


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


RE: Too many calls to new?

2003-06-24 Thread Keith Rollin
 Ah.  Just so I'm clear on this -- the database resides in 
 storage space, but
 since I'm loading every value of the database into a graph, then I'm
 effectively creating a copy of the database in dynamic 
 memory, which is very
 limited in size on some devices?

Correct.  Take a look at some of the SDK samples like MemoPad to see how they manage 
to get by with hardly any dynamic heap allocations at all (I seem to recall that 
MemoPad allocates only one chunk out of the storage heap, which is used to hold the 
text of the variable form caption Memo xx of yy).

 Is dynamic memory faster than storage memory?

It's not faster for reading, but it is faster for writing (since writing to the 
storage heap requires calls to DmWrite and friends).

-- Keith

--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/