See:
What and where are the stack and heap?
In particular:
"The OS allocates the stack for each system-level thread when the
thread is created. Typically the OS is called by the language runtime
to allocate the heap for the application."
and...
...while the stack is allocated by the OS when the process starts
(assuming the existence of an OS), it is maintained inline by the
program. This is another reason the stack is faster, as well - push
and pop operations are typically one machine instruction, and modern
machines can do at least 3 of them in one cycle, whereas allocating or
freeing heap involves calling into OS code.
Thus, I believe the answer to your question is that you'd need full root access to the operating system's internal memory paging system to keep track of all objects (particularly on the heap). As far as I know, all garbage collection systems use a reference count approach to manage heap memory allocation and don't directly access the operating system's heap allocation records. There are very good security reasons for this I'm sure.