At 8:27 AM -0700 4/12/01, Nitin Nangia wrote:
>i'm facing a problem wherein i get strange memory
>crashes in my shared library if i pass memory
>allocated on the heap using MemPtrNew intto it from
>another application.
Memory allocated by an application is freed by the OS when the application exits. So
if you pass one of these blocks of memory to the shared library, then quit the app,
then later try to access that block of memory in your shared library (from the same or
another application) it will be invalid. This is most likely the source of your
crashes. This behavior is explained in detail in the memory management section of the
docs.
One way to avoid this behavior is to give ownership of the memory block to the system
before the application exits using MemHandleSetOwner(h, 0) or MemPtrSetOwner(p, 0).
Another way is to use Feature Manager memory, though doing so requires that you use
DmWrite to modify its contents (which can either be a good thing or a bad thing,
depending on what you're trying to do).
Regards,
Jim Schram
Palm Incorporated
Partner Engineering
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/