动作 - 对内存管理本原/非原始对象之间的差异? [英] ActionScript - Difference Between Primitive / Non-Primitive Objects for Memory Management?

查看:156
本文介绍了动作 - 对内存管理本原/非原始对象之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是,原始类型( UINT,字符串,数字等。的)一类的不需要被设置为null垃圾收集。

my understanding is that primitive types (uint, string, Number, etc.) of a class do not need to be set to null for garbage collection.

例如,我不需要写这个配置()在下面的类方法:

for example, i am not required to write this dispose() method in the following class:

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;
        }
    }
}

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

if this is true, which i believe it is, what is the difference between objects of primitive types and objects of non primitive types concerning memory allocation?

推荐答案

据我所知,GC逻辑的flash播放器虚拟机的最完整和详细的解释位于的在亚历克斯Harui的博客,写早在2007年。直接链接: GCAtomic.ppt

As far as I know, the most complete and detailed explanation of GC logics in flash player VM is located in the blog of Alex Harui, written back in 2007. Direct link: GCAtomic.ppt.

这里是从格兰特斯金纳GC一些有用的提示。

GC逻辑处理引用和引用计数。既然你无法获取引用原始的动作,你可以在这方面无能为力GC。

GC logic deals with references and reference counting. And since you can not obtain a reference to a primitive in ActionScript, you can do nothing about GC in this aspect.

修改刚想起另一尼斯组文章GC和资源管理通过格兰特斯金纳。

EDIT Just remembered another nice set of articles on GC and resource management by Grant Skinner.

这篇关于动作 - 对内存管理本原/非原始对象之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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