Java is increasingly gaining acceptance as an application platform for embedded systems. Many of the embedded systems, such as mobile devices and smart cards, have very limited memory spaces. Therefore, reducing memory space required to run Java applications is critical for memory-constrained embedded systems.
In this thesis, we present a static analysis technique for reducing heap space requirements of Java applications. We develop a new data-flow analysis for detecting dead references to objects, which are defined as references that are not removed although they are no longer necessary. Our analysis technique also determines program points where we can remove dead references by assigning null to reference fields. Assigning null to those fields allows a garbage collector to reclaim objects referenced by the fields in a more timely manner, and hence, saves heap space occupied by the objects.
We have implemented our data-flow analysis algorithms for Java applications and applied it to a number of benchmark programs. Guided by the list of dead references and null-assignable program points, we have modified the source code of the benchmark programs. Our experimental results show that space saving up to 8.1% can be achieved, but savings vary from application to application.
Since our analysis may generate false positives, the technique is not applicable to automatic program transformation. However, the results presented in this thesis demonstrate that our analysis is practical for large applications and effective for reducing heap space requirements.