本文介绍了管理资源,以尽量减少垃圾收集活动,提高性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,需要使数据在每帧时,有一个变化的图形设计,矢量绘图应用程序。这个问题是,如果用户移动节点,将有每一个帧期间的变化。这不是一个问题与数据的一个微小的量,是一个主要减速时,有比数据的次要量的任何更

I am working on a graphic design, vector drawing application that needs to render the data in every frame when there is a change. The issue is, that if the user is moving nodes, there will be changes during every single frame. This is not an issue with a tiny amount of data and is a major slowdown when there is anything more than a minor amount of data.

的原因是为了使余preform计算和内部阵列存储数据。然后,当负责计算的函数完成后,气相色谱简单地丢弃该数据,并在下一次调用该函数时,我们创建新阵列和新的数据。

The reason is that in order to render I preform calculations and store data inside arrays. Then when the function responsible for the computation is done, the GC simply discards the data and next time the function is called, we create new arrays and new data.

在C ++中,我可能会在内存中分配空间和写入空间(一遍又一遍)。我可能会提高性能的方式。在语言中,在我们的GC我不能分配空间的方式。我要做一个丑陋的黑客,我定义一个数组作为类的成员,然后写从功能上说阵列一遍又一遍,虽然该数组仅用于一个功能,并且不使用类的其他方法。

In C++ I would probably allocate space in the memory and write to that space(over and over). I would probably improve performance that way. In languages that us GC I cannot allocate space that way. I have to do an ugly hack where I define an array as a class member and then write to that array from the function over and over although that array is only used in that one function and is not used by other methods of the class.

我的问题是,什么是重用在使用GC语言的存储空间的最佳方式?

My questions is, what is the best way to reuse memory space in a language that uses GC?

推荐答案

对象池将是其中最主要的,在这里看到:的gotoAndPlay教程

Object pooling would be the major one, see here:Gotoandplay Tutorial

另外 10绕前提示GC

我也建议你通过Flash Player的垃圾收集系统的格兰特的解释看,这是相当独特的,并了解Flash如何处理的数据是数据密集型的脚本非常重要。

I would also suggest you read through Grant's explanation of the garbage collection system in the Flash Player, it's quite unique, and understanding how Flash handles data is quite important to data intensive scripts.

这presentation

这篇关于管理资源,以尽量减少垃圾收集活动,提高性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 06:48