By: J. Noble, C. Weir
Published in: PLoPD4
Patterns for memory-challenged systems.
Category: Memory Management
Summary: Patterns for memory-challenged systems.
You're developing a small system with stringent memory requirements. Imagine the system even smaller than it really is. Develop a culture where saving memory is a habit. Use design and code reviews to exorcise wasteful features and techniques. Use Captain Oates, Exhaustion Test, Make the User Worry, Memory Budget, Memory Performance Assessment, and Partial Failure
You're using Think Small. Draw up a memory budget and worry about it a lot. Define targets for the system and for each component. Targets increase the predictability of the memory use. Developers with targets can make local decisions where it's easy to identify problem areas.
You're using Memory Budget, but memory requirements are unpredictable. As development proceeds, it's clear that some will need more than their budgeted memory allotment. Include overdraft provisions in the budget.
You're using Memory Budget, but it's difficult to predict memory requirements. A lot depends on the user. Make the memory model explicit in the user interface so that the user can worry about memory.
No matter how well you reduce the program's memory requirements, there will always be situations when the program runs out of resources. To handle unlimited memory requests, allow the program to fail partially or have behavior degrade, but not stop. Use Exhaustion Test
To prioritize memory demands, when a system runs out of memory, surrender memory used by less vital components rather than have the most important tasks fail.
To be sure the program will work correctly when out of memory, use testing that simulates memory exhaustion. Verify that the program uses Partial Failure or Make the User Worry
Category: Memory Management, Testing
To stop memory constraints from dominating the design process, implement the system, paying attention to memory requirements only where these have a significant effect on the design. Once the system is working, identify the most wasteful areas and optimize their use.
Category: Design Process, Memory Management