if have following code
public int somefunct() { int temp; int32.parse(txtbox.text, out temp); return temp; } i using temporary int. after function execution over, when memory of int (or temporary object used) released? or, there code called explicitly?
in case temp variable either allocated on stack, or in register.
i "most likely" because exact workings of level of code implementation specific far know.
on stack deallocated when method returns. if placed in register register reused @ point , cease specific meaning when method returns.
in case think summarize, "deallocated" when method returns.
also note while types in .net inherits system.object, phrase "object" used reference types. int value type, not allocated on heap.
if mean "what happens temporary objects" garbage collector collect @ later indeterminate point in time.
for instance piece of code:
public void log(int value) { debug.writeline(value); } here using this overload of debug.writeline takes object parameter. in case int value boxed means object allocated on heap hold our int.
this temporary object used debug.writeline , no longer considered "in use". @ future indeterminate point in time, garbage collector collect it.
Comments
Post a Comment