On Wed, Aug 13, 2003 at 12:57:15PM -0000, drvirens wrote:

> AFAIK, the implementation of new keyowrd on Palm is such that it 
> always calls the MemPtrNew() API of the Memory Manager 
> internally...so you are really given a direct physical address by the 
> system. Since this poiner is not locked, it may become a dangling 
> pointer should the system run a "compaction" routine or other similar 
> job behind your back. 
> 
> So, the wise thing to do would be to use the new only if you are sure 
> you are not gonna need the object for longer periods of times. 
> 
> Guys, please correct me if I am wrong. 

You're wrong on this part. MemPtrNew allocates a non-movable chunk that
is immune to compaction or defragmentation. MemHandleNew allocates a
movable chunk that will be essentially flagged as non-movable when you
lock it with MemHandleLock. 

It's perfectly safe to allocate long-lived pointers with new. The only
thing is that it can cause memory fragmentation (this is generally true
in any OS, but on small-memory systems it can be more of a
problem). However, the same thing can be said if you allocate a handle
and lock it for the length of the program.

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

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

Reply via email to