[英]iOS Development: How can I tighten up my Core Data memory usage?
I'm very new to Core Data and I'm still learning how it all works under the hood. 我对Core Data并不陌生,但我仍在学习如何在后台进行所有工作。 My Core Data model hierarchy contains a user profile, which contains a set of ten different levels using a one-to-many relationship, with each level containing 30 different puzzles also using a one-to-many relationship. 我的核心数据模型层次结构包含一个用户配置文件,该用户配置文件包含使用一对多关系的十个不同级别的集合,每个级别也包含三十个不同的难题(也使用一对多关系)。
UserProfile (x1) -> Level (x10) -> Puzzle (x30), for a grand total of 311 objects per user profile
The levels and puzzles models are used to store the user's progress as the user sequentially solves the puzzles. 当用户顺序解决难题时,级别和难题模型用于存储用户的进度。 When the game runs for the first time, the game reads all the levels and puzzles data from a plist and generates Core Data objects (table rows) that will be used store the users progress as they play the game. 当游戏首次运行时,游戏会从plist读取所有关卡并解谜数据,并生成Core Data对象(表行),这些对象将用于存储用户在玩游戏时的进度。 In other words, the list of Core Data objects doesn't grow as the user plays the game, instead it's all created at the start and the properties of the objects change as the user plays the game. 换句话说,Core Data对象的列表不会随着用户玩游戏而增长,而是在开始时全部创建,并且对象的属性会随着用户玩游戏而改变。 I suspect this is inefficient, tho my questions remain the same... 我怀疑这效率低下,但我的问题还是一样...
I apologize if these are outrageous questions and I apologize for their length, and thanks so much for your wisdom! 对于这些令人毛骨悚然的问题,我深表歉意。对于它们的冗长,我深表歉意,并非常感谢您的智慧! I'm heading back to the Core Data docs right now, I just thought I'd post these questions while I continue the self-teaching. 我现在回到核心数据文档,我只是想在继续自我教学的同时发布这些问题。
This answers your 'lazy load' question. 这回答了您的“延迟加载”问题。 Core Data to-many relationships. 核心数据对多关系。 Are they Lazy Load? 他们是懒加载吗?
I wouldn't worry about 6MB of memory unless you see a performance issue. 除非您看到性能问题,否则我不会担心6MB的内存。 You can always check it with the included utilities. 您始终可以使用随附的实用程序进行检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.