mob
var
Datum = new(params)
verb
ChangeVar()
var/Datum/D = new(new_params)
src.Datum = D
return
Suppose I have a variable datum for something but I instantiate a new datum and set a variable to this new datum. Does the old datum sit in memory or does it get collected with the garbage? Something like this
|
Dec 16 2013, 3:35 pm
Best response
|
|
Since the first datum no longer has anything referencing it, the garbage collector takes it away to the data furnaces.
|
In response to LordAndrew
|
|
LordAndrew wrote:
Since the first datum no longer has anything referencing it, the garbage collector takes it away to the data furnaces. I lost it at data furnaces. Moreover, LA is right. You are going to want to avoid excess initialization of datums if you can, though. Initialization has a certain burden of overhead while the VM sets up, registers, and stores the datum. Optimally, you will want to actually change the datum's values if possible, rather than creating a new one and getting rid of the old one. It's just cleaner. |