Abstract:In order to reduce the cost of java virtual machine garbage collector, we propose a stack-allocation based garbage collection algorithm. We improve the stack frame and make it support object storage, analyse and identify stack-allocation object when compiling the java source code, and mark the object with new byte command. Stack-allocation object will be allocated from java stack and released immediately when leaving its scope. Other object will be allocated from heap and released by garbage collector. Experimental results show that, compared with traditional garbage collector, the new algorithm improves the performance of allocating and releasing, reduces the burden of garbage collector and runs faster.