在 android 中,我使用 hashmaps 和 sparsearrays 和 sparseintarrays。在我使用的函数中,它们有时是临时对象。在函数结束之前,是否清除 map 数据是一个好习惯?
谢谢
最佳答案
In android, I make use of hashmaps and sparsearrays and sparseintarrays. In functions I use them sometimes are temporary objects. Before the function ends, it is a good practice to clear the map's data or not?
不,那什么也做不了。
I thought, if you clear it, then you get back the memory right away instead of waiting for garbage collection. So doesn't that make it work it?
清除集合只会清除对集合中项目的引用,因此您仍然需要等待垃圾回收来取回内存。
关于java - 当函数在 android 中结束时清除 map 是否值得?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25612363/