C# - Get number of references to object

前端 未结 5 2006
醉梦人生
醉梦人生 2020-12-05 05:37

I\'m trying to write a simple Resource Manager for the little hobby game I\'m writing. One of the tasks that this resource manager needs to do is unloading unused resources.

5条回答
  •  渐次进展
    2020-12-05 06:16

    As already told by other users, what you are trying to achieve is already made by the GC, and can be fine tuned using a WeakReference.

    This imply that in managed environments like .NET, java, and so on, this is a non-problem.

    Since the low-level framework architecture isolates you from the memory management, if you still need for that kind of functionality, I strongly suggest you to review your own code architecture, cause it would mean that you are doing some sort of bad-practise in memory management

提交回复
热议问题