+ 2
Is it better to delete variables at the end of functions?
I read that deleting them is just deleting the references.. is it true? does that differ according to the language or it is general?
7 odpowiedzi
+ 2
What language?
+ 2
It is important to free up memory in in C and C++ because there is no garbage collection.
in other languages that have garbage collection, less so, as memory is eventually freed up when the variables are out of scope.
+ 1
I am not sure about what you read, :-)
Good practice in that area is language specific...
You may want to read about memory allocation and garbage collection, reference counting, and heap vs. stack, and the role of constructor/destructor (esp. in C++)
0
Whatever.. I mean is it a good practice?
You ask about the language.. so it depends?
0
In python (I believe) there is reference counting and garbage collection. The variable dies when nothing "knows about it in the rest of the application.
0
thank you so much.. at least now I have key words to look for.. am grateful ;)
- 1
I am learning python now.. and thought that whenever I finish the function.. its local variables die.
but in java I think it is not the same.. I am a little lost