If you check out "Palm Programming: The Developers Guide" by Neil Rhodes (O'Reilly Press), you will find a good example of how he optimizes the use of memory with records that contain variable length strings. Chapter 6 has what you are looking for I think. Look for his references to to "packing" and "unpacking" a record.
Mitch Fawcett Tapnsee Software www.tapnsee.com Home of SuperList3 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Ryan > Bruner > Sent: Thursday, July 03, 2003 2:22 PM > To: Palm Developer Forum > Subject: How to save space??? > > > > > I was making updates to my code and decided to attempt to reduce the > amount of memory each record takes up. So, after doing some judicial > rearranging and more efficient use of fields in my data structure, I > reduced what was over 100 bytes to around 65. So, this would seem to > be a 35% reduction in space. > > Now, the catch is that one of the fields, for efficiency sake, is a > string of small size. If, however, the size of the data exceeds the > size of that field (set to 24 bytes now, previously it was 50 bytes), > then I store the data in a data record that ONLY contains the string > information. This "notes" field method allows me to have quick access > to most notes (which tend to be small for my application), but allow > larger notes as well. > > The problem is that after all this conversion, my memory usage, after > conversion of the data from the old format to the new format is > actually no different. It seems that the few additional records added > due to some notes being between 24 and 50 bytes in length added enough > data to basically eliminate any benefit from reducing the memory > footprint of the other 300+ records. > > This seems to indicate that there is a lot of extraneous data > maintained for each record by the PalmOS itself. Is there a way to > make a record not take up as much space from the OS side of things??? > > One might question why I'm not "compacting" the data for each record. > Well, I do some intensive statistical calculations on all of the > records at times, and so using a fixed structure prevents the need for > parsing and copying the data for each record, which speeds things up > dramatically. > > Ryan > > > -- > For information on using the Palm Developer Forums, or to > unsubscribe, please see http://www.palmos.com/dev/support/forums/ > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
