At 12:26 PM -0700 5/24/99, Ronald H. Nicholson Jr. wrote:
>There doesn't seem to be any explicit mention of how to free, delete
>or dispose of a handle from DmNewHandle in Part III of the OS manual.
>Is there a DmHandleFree or DmDeleteHandle?  Or will MemHandleFree
>work without corrupting the heap?  (or even MemPtrFree?)

The MemPtr and MemHandle routine all work on storage heap chunks as well as
on dynamic heap chunks.  The only real difference is that MemPtrNew and
MemHandleNew always allocate from the dynamic heap, and also you must use
DmWrite to write to chunks in the storage heap.



At 1:28 PM -0700 5/24/99, [EMAIL PROTECTED] wrote:
>Memory allocated by DmNewHandle is a bit risky because such memory isn't
>associated with a database.  It is orhpaned memory.  This means the user
>can't delete it.  Orhpaned memory is cleaned up when Palm OS is reset, and
>many users go a long time without resetting (I wish they could go
>forever...)
>
>It is therefore important to attach memory allocated using DmNewHandle to a
>database.

I'll agree with Roger that it is risky to use non-database memory in the
storage heap.  I'll disagree, however, with the conclusion that this means
you must attach memory to a database.

Obviously, you should avoid leaking memory in the storage heap.  Assuming
you're careful with your allocates and frees, I think the risk is minimal.


At 9:06 AM -0700 5/25/99, Alan Pinstein wrote:
>I think the OS keeps track of DmNewHandle allocations in the appInfo block
>of the application's runtime (NOT the DB appInfo block) and cleans up after
>apps quit....if there was a crash, at each reset, the OS walks the data
>heap to make sure all chunks are attached to a DB and if not it frees them,
>since no one has a refernce to the chunk, it can be safely freed.

Alan should really understand what he's writing before he writes
authoratatively... in this case, he's giving out incorrect information.
(But then, we all do that from time to time.)  Interested parties are
invited to read the memory manager whitepaper at
http://oasis.palm.com/devzone/knowledgebasearticle.cfm?article_id=1145 for
an in depth and almost completely correct discussion of the Palm OS memory
architecture.

The OS does not keep track of DmNewHandle allocations by application at
all.  All non-DB storage heap chunks (from any application) are essentially
identical.  At reset, the OS will delete any and all so-called "orphan"
storage heap chunks, but there is nothing that will clean these up
beforehand.  The storage for all orphan chunks is grouped under "Palm OS�
Software" in the Launcher's "Info" dialog.

There is no easy way to test for orphaned data memory.  If you're worried,
you can use the console (in the simulator or debugger) and do a "hd 1",
which on the 3.0 and later releases will dump the storage heap.  Chunks
that are not associated with any database are readily identifiable.

                                --Bob



Reply via email to