场景工具包内存管理使用swift [英] scene kit memory management using swift

查看:95
本文介绍了场景工具包内存管理使用swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑我是如何使用swift在场景工具包中释放内存的。每当我从collada文件创建SCNNode时,它都会导入几何体,创建物理对象,并从jpg文件中设置材质。由于某种原因(即使文件大小低于300k),这会占用10 mb的ram,但无论如何。每当从父节点中删除它时,零ram释放,我不明白为什么。我可以使用什么代码来真正删除对象?我找不到关于这个主题的任何文件。这只是一个普遍的问题,所以这里不需要代码。

I'm perplexed as to how I am to free up memory in scene kit using swift. Whenever I create an SCNNode from a collada file, It imports geometry, creates a physics object, and sets a material from a jpg file. This takes up 10 mb of ram when creating a new object for some reason (even though the files sizes are under 300k), but whatever. Whenever it is removed from the parent node, zero ram frees up, and I do not understand why. What code can I use to TRULY remove the object? I can't find any documentation on the subject. This is just a general question, so no code is needed here.

推荐答案

所以我发现我需要做的是设置我的游戏对象上的纹理在从父对象中删除之前为nil。正如一般规则,我在删除节点之前开始将所有纹理设置为nil。无论如何,这解决了我的记忆问题。

So I found out what I needed to do was set the texture on my game objects to nil before removing them from the parent. Just as a general rule, I started setting all my textures to nil before deleting the node. Anyway, this solved my memory problem.

这篇关于场景工具包内存管理使用swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆