There are a lot of "it depends here", ranging from what your code is doing to what browser you're running in. However, if your object is JIT compiled to not use a map for its attributes, then the number should be an 8 byte double stored inline inside the object. Nulling it will do nothing.
The string and the myclass instance will be a pointer to memory allocated outside the object (since a string can be arbitarily many bytes, it can't be stored inside the object. A compiler could conceivably store one instance of the string in memory and never free it, however). Nulling them can allow the garbage collector to free them before the main object goes out of scope.
However, the real question is why you're worried about this. Unless you have profiled your code and identified garbage collection or memory leaks as a problem, you should not be trying to optimize GC behavior. In particular, unless your myobj
object is itself going to be live for a long time, you should not worry about nulling fields. The GC will collect it when it goes out of scope.
myobj
but ensure all of its values do not occupy memory or do you want to totally wipemyobjt
from memory? – Carlynnemyobj.theClass = null;
..." No, it's not. – Cassadymyobj
. And if I want to do that, I'm pretty sure it's necessary to domyobj.theClass = null
if I don't want to cause memory leaks. – Middlebuster