Check if a variable exists - Memory ? #255
Replies: 5 comments
-
Posted at 2014-04-12 by DrAzzy This is nasty! Does 'delete varname' clean up after it? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-04-13 by Sacha Hi DrAzzy, Yes as any other variable it could be deleted. It gives the mem back. Sacha |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-04-14 by graf I believe it's this one espruino/Espruino#63 Just an idea I didn't test, but how about
Would that make sense? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-04-14 by Sacha Yes, it looks like. Thanks. Will try it. Sacha |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-04-14 by @gfwilliams Or you can do At the moment this is a frustrating issue - but it's surprising how rarely it's actually a problem if your code is working as expected. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-04-12 by Sacha
Hi Espruinos,
I just searching a proper way to detect if a variable is defined/exists without loosing memory. Yes it's all about memory....
I tried it in two ways:
and
Here is the memory loosing code:
Each test if the variable exists creates the variable as undefined and uses memory.
You will see it when you output the array like this:
Output:
Many thanks for your help
Sacha
Beta Was this translation helpful? Give feedback.
All reactions