--- Brad Figler <[EMAIL PROTECTED]> wrote: > Are the entries stored in the database moveable (by the > memory manager)?
Anytime you have a handle to something and have to lock the handle to get a pointer to the object, you should assume that that object is something that can be moved around by the OS when it needs to allocate memory. Calling MemHandleLock() makes it temporarily unmovable. Calling MemHandleUnlock() makes it movable once again. > I have created a database that just stores text strings > and I am putting those test strings in a list control. > Currently, I am storing the address of returned to me > when I lock down the record returned by the data manager > via DmGetRecord. I am then unlocking the memory and > releasing the record. I believe that this is probably > a really bad idea because I do not keep the records locked > down therefore the memory manager is free to move the > memory if needed, which would make my pointers invalid. Yes, it sounds like a Very Bad Idea. > Is it better to keep the records locked down so that the > memory manager cannot move them, or is it better to copy > them to dynamically created memory and keep two copies of > the data? The answer depends on how many strings you are talking about and how much memory is free. As you lock down more chunks of memory, it becomes more fragmented, thus increasing the likelihood of failed memory allocations. But the memory has to be locked at any time you might access it. If you are creating a list, there are two ways to go (actually 3 ways, but a static list won't work for your situation): 1) Create a dynamic List that gets its contents by reading from the database and either a) keeping it open and the records locked as long as the list is present, so the List contains pointers to database records. b) copying each string to memory your app owns, so the list contains pointers to that memory. In this case you can close the DB after you create the List. 2) Use a callback function to draw each row of the list when asked to (see LstSetDrawFunction). In this scenario, you will probably keep the database open for the duration, but only lock each record as it is needed for drawing. You may find David Fedor's List recipe helpful. Its at http://www.palmos.com/dev/support/docs/recipes/lists.html __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
