-
• #2
Yes, you can do that - but it won't save you a great deal of memory (only a few variables)...
While the
TRILED
object reference will be deleted, the object itself will still hang around because it's used byL1
,L2
,etc.You can check how much memory you are using before and after the delete using
process.memory().usage
-
• #3
Since you - @Francesco - use objects that creates a namespace for methods, you can chose shorter method names, such as sR(), sG(), ...and sC(r,g,b) - for setting a particular or continues color and that will save you probably more space than deleting the constructor (source)... assumed your overall code will not be shrink wrapped (bulked and minified).
-
• #4
thanks both for the reply, I have solved in other way that I'll explain:
For my partcular case the core of the software is a function called at regular intervals, and I choose at boot time what function run (I have defined N function, one for each "mode").
Considering that other N-1 functions will be never called I can safely delete it withdelete MyOBJ.prototytpe.myfuncion
before the chosen function is called
Hi,
I have wrote a software which uses a lot of object instantiated only at the boot.
I need to save memory and delete unused data.
for example, this code allow me to instantiate more objects each assigned to a multicolor LED:
The question is: Can I safely delete the TRILED object after their initialization? Can safely call the method set* and reset in the future ?
It seems to works but I need a confirmation, I want to do this: