(30)Static collections性能
招數30:orm
靜態集合對象
If a collection is static, make sure it only contains the objects you need. If the collection is iterated over often, then the performance can be slow if you don’t remove unnecessary objects. Objects in a collection will be held in memory, even if they have been disposed of, which can also lead to a memory leak.
若是一個集合是靜態的,確保它只包含你須要的對象。若是集合常常被遍歷,若是你不移除沒必要要的對象,那麼性能可能下降。集合中的對象將會佔用內存,這也會致使內存泄漏,即時它們已經被處理過。內存