Patent ID: 7424589

Claim:
A method for tracking memory usage of tasks in a shared heap, comprising: performing a full garbage-collection operation on the shared heap, during which a base memory usage is determined for a task; maintaining a memory allocation point for the shared heap, wherein the memory allocation point indicates a next location from which memory will be allocated to tasks; advancing the memory allocation point as memory is allocated for tasks; after switching to the task during a task context-switch, remembering a value associated with the memory allocation point as an initial allocation point; during execution of the task, periodically estimating an amount of newly allocated memory for the task by calculating an interval between the initial allocation point and a subsequent allocation point for the shared heap, where the subsequent allocation point is associated with a subsequent location of the advancing memory allocation point; combining the base memory usage and the estimate of newly allocated memory to determine an estimate of current memory usage for the task; using the estimate of current memory usage to determine whether the task is likely to be violating a memory quota; triggering a remedial action when the task violates the memory quota; and after the task has been switched out during a task context-switch and a subsequent task is switched in, remembering the current location of the advancing memory allocation point as an initial allocation point for the subsequent task; wherein the current memory usage is estimated for the task at a finer time granularity than at every full and/or generational garbage-collection operation.