A method for managing memory in a multi-tasking virtual machine, involving
suspending a first task for garbage collection of a plurality of
concurrently executing tasks, promoting at least one object associated
with the first task to a old generation using a gap buffer to obtain a
promoted object, wherein the gap buffer stores a gap created by objects
directly allocated by at least one of the plurality of concurrently
executing tasks, locating the promoted object using the gap buffer,
traversing the promoted object to determine whether a first referenced
object exist, and promoting the first referenced object using the gap
buffer, if the first referenced object exists.