This appendix describes some techniques for testing and fixing out-of-memory (OOM) robustness issues and memory leaks. OOM robustness means that when some memory allocation operation fails, the error is handled gracefully. The program should not crash. It should not produce incorrect results. It should not leak memory.
As a case example, I will be using Redland, a set of open source libraries for processing resource description framework (RDF) data. RDF is a set of related World Wide Web Consortium (W3C) specifications. They were originally designed as a metadata model. Currently RDF is used for modeling all kinds of data, using various syntax notations. Usually the data is about web resources and RDF is the core of what is often called the 'semantic web'.
In a project I was working on, I wanted to convert existing legacy data sources to RDF and run SPARQL queries on them. SPARQL is an SQL-like standardized query language for RDF data. Instead of writing everything from scratch, I decided to port existing open source components to Symbian OS and ended up porting Redland. It provided me with RDF parsers, serializers, storage and a query engine that supports SPARQL. Redland is written in C without any complex dependencies. Porting the core functionality was relatively straightforward using the P.I.P.S. libraries for Symbian OS. Redland's Apache 2.0 and LGPL 2.1 dual license was also generous enough for my needs.