actionscript-3 - ActionScript - 用于内存管理的原始/非原始对象之间的区别?

标签 actionscript-3 memory-management garbage-collection primitive-types

我的理解是,不需要将类的原始类型(uint、string、Number 等)设置为 null 以进行垃圾收集。

例如,我不需要写这个 dispose()以下类中的方法:

package
{
//Imports
import flash.display.Shape;

//Class
public class DrawSquare extends Shape
    {
    //Properties
    private var squareColorProperty:uint;

    //Constructor
    public function DrawSquare(squareColor:uint)
        {
        squareColorProperty = squareColor;

        init();
        }

    //Initialize
    private function init():void
        {
        graphics.beginFill(shapeColorProperty);
        graphics.drawRect(0, 0, 200, 200);
        graphics.endFill();
        }

    //Dispose
    public function dispose():void
        {
        squareColorProperty = null;
        }

    //Get Shape Color
    public function get squareColor():uint;
        {
        return squareColorProperty;
        }
    }
}

如果这是真的,我相信是这样,关于内存分配,原始类型的对象和非原始类型的对象之间有什么区别?

最佳答案

据我所知,flash player VM中GC逻辑最完整详细的解释位于in the blog of Alex Harui, written back in 2007 .直达链接:GCAtomic.ppt .

And here are some useful hints on GC from Grant Skinner.

GC 逻辑处理引用和引用计数。并且由于您无法在 ActionScript 中获得对原语的引用,因此您在这方面对 GC 无能为力。

编辑 刚想起另一个 nice set of articles on GC and resource management通过格兰特斯金纳。

关于actionscript-3 - ActionScript - 用于内存管理的原始/非原始对象之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6570105/

相关文章:

actionscript-3 - 在 AS3 中,如何覆盖 [] 运算符的 setter 和 getter?

flash - 在 Actionscript 3.0 中访问父属性/方法

ios - 收到内存警告和应用程序崩溃 - iphone

c++ - C++ 标准要求 new char[] 产生对齐内存的意图是什么?

c# - 在什么情况下,引用会指向排队等待垃圾回收的对象?

c# - 在 C# 中使用 ArrayPool 重用从字符串到字节数组转换的内存?

apache-flex - ActionScript 中的绑定(bind)如何工作?

flash - 通过 ActionScript 关闭网络摄像头使用

php - 需要在 PHP 中使用最少的内存使用的类似数组的结构

.net - 为什么垃圾收集器不收集任务对象