Optimising Memory Use (space)
Examine time/space tradeoffs
Examine which data should be expanded on each use and which should be cached expanded
Examine the many possible compression formats, algorithms, libraries available: ad hoc to Z-lib
Strip asserts and other instrumentation for release
Minimise heap use: it is slow and inefficient
Notes:
EXAMPLE: TW Palm target made space optimisation critical (40kB heap for KVM Java application); required optimisation for space, keeping much data compressed on client, stripping out all debug instrumentation for release, lots of testing of different routes through code.
- How much and what sort of memory can you use (including slower, NV, read-only and ROM areas, secondary or remote storage)?
- Can you detect available resources at runtime?
- Do you have even more constrained circumstances, eg in interrupt or background event handlers (eg on Palm when another application is running)?
- Does your data allow convenient and fast in-memory decompression? Does code to do decompression take more space you could use for the data?
- Can you get your compiler to optimise code for space?
- Can different linking style or third-party tools reduce space taken?
- Are application and run-time space separate?
- Consider variable-length representations such as ?- and ?- format integers, prefix-coded strings, especially for sparse or sorted data sets.
- Have you run a coverage tool to eliminate dead code and uncalled routines?