哪种数据类型垃圾收集器释放内存

哪种数据类型垃圾收集器释放内存

本文介绍了哪种数据类型垃圾收集器释放内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我了解到使用类创建的对象是由垃圾收集器收集的,但是结构对象不能被GC收集。我知道结构是值类型并存储在堆栈中,类是存储在堆中的对象类型。



但是,我猜GC只收集托管代码。那么这是否意味着Structure类型是非托管代码?







GC会处理仅存储在堆中但不存储在堆栈中的对象吗? />


如果是,那么int数据类型呢?类型为int的对象,不是由GC管理的吗?



有人请澄清我的困惑。



谢谢和问候,

Atul Sharma

解决方案

Dear All,

I learnt that the Objects created using Classes are collected by Garbage collector, but the object of struct can not be collected by GC. I know that structure are value type and stored in stack and classes are object type stored in heap.

But, I guess GC collects managed codes only. So does that mean that the Structure types are unmanaged code?

OR

GC take care of objects that stored in Heap only and not in Stack ?

If yes, then what about int data type? Is object of type int, not managed by GC?

Some one please clarify my confusion.

Thanks & Regards,
Atul Sharma

解决方案


这篇关于哪种数据类型垃圾收集器释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 16:22