some fundamental questions about memory usage

im only experimenting a little with j2me. therefore ive taken the nokia 7210 emulator, which has nicely a memory usage monitor tool integrated.

so i made a little experiment, just for getting a feeling in the memory management:
i just created a very basic midlet with a canvas, doing absolute nothing and watched the memory usage:

default

size : 215040
used : 21456
free : 193584

then i tried to compare this result to the same midlet expect adding a class-global int-var:

int

used : 21500

–> ??
shouldnt the default-value of the heap-used-value be only increased by the value of an int-var (4bytes) ?

another example with 2 int-vars:

int 2x

used : 21528

–> ??? this tiime i expected to get the difference between the default-memory usage and the one with one int-var twice … but it isnt…

what do i get wrong ?

I don’t think you can be that precise when measuring memory in a VM. The phone may or may not have released an object for garbage collection when measuring.

Chances are it’s just the classloader creating some garbage when loading your classes.

shmoove