I have the same program (same binary) running in different modes. From
GC stats I see they're using the same amount of heap now (209m) and
the stack is small. But in top's RES column, I see one is using 270m
memory and the other one is using 622m. Forcing heap compaction does
not change the numbers.

I don't quite understand this difference. A program's memory usage
should be code, static data, heap and stack. For the same binary, code
and static data segment should be the same, and now that GC stats
tells me heap and stack are the same, why there is a 352m difference
in memory usage?

Thanks