垃圾收集(或永久存在的对象) [英] Garbage collection (or objects that live forever)

查看:62
本文介绍了垃圾收集(或永久存在的对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户正在使用LLBLgen来使用数据对象,这些对象又被添加到对其他类的引用中,因此我发现ibject A保持活动状态并具有对b的引用- > - d-> e.

I have a customer that is using LLBLgen in order to use data objects which are in turn added to references to other classes, so what I am finding is that ibject A is being kept alive and has references to b -> c-> d -> e.

就最佳实践而言,有什么更好的设计计划来防止此类问题发生?

In terms of best practice whats a better design plan to prevent issues such as this?

其他信息:

A类包含一个实例,该实例包含由B类返回的对象.这似乎就是原因. (B)类永远不会得到GC.我已通过删除对类B的引用来确认了这一点(破坏了代码,但我对内存更感兴趣 问题),那么如果是这样,那么第二个类如何返回任何返回应该消失的非值(如另一个对象的引用数据)的值?

Class A contains an instance that contains an object returned by class B. this would appear to be why  class (B) never get GC'd. I have confirmed this by removing the reference to class B, (breaks the code but I am more interested in the memory issue) so if thats the case how does a second class return anything which returns a non value (reference data like another object) that should go away?

推荐答案

不再需要将对象A中的引用删除到对象B.

Remove the reference in object A to object B when it is no longer needed.


这篇关于垃圾收集(或永久存在的对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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