Memory leak tool tells me zero leaks but memory footprint keeps rising

前端 未结 6 1299
悲哀的现实
悲哀的现实 2021-01-23 06:42

I\'m running through some memory profiling for my application in SDK 3.2 and I used the \'Leak\' profiler to find all my memory leaks and I plugged all of them up. This is a sc

6条回答
  •  伪装坚强ぢ
    2021-01-23 06:51

    Depending on how you have your object graph constructed in Core Data, it's memory use can grow unexpectedly large.

    A common mistake is to store objects inside a complex and often faulted (loaded into memory) entity. This cause the big blob to be loaded/remain in memory whenever any other part of the entity is referenced. As you object graph grows, it eats more and more memory unless you actively delete objects and then save the graph.

    For example: You have an person entity with lots of text info e.g. name, address, etc as well as a large photo. If you make the photo an attribute of the person entity it will be in memory anytime the person entity is faulted. If you get the attribute name, then the photo attribute is in memory as well.

    To avoid this, blobs should be in their own entity and then linked to other entities in relationships. Since relationship objects are not faulted until they are called directly they can remain out of memory until needed.

提交回复
热议问题