| Package | flash.errors |
| Class | public dynamic class MemoryError |
| Inheritance | MemoryError Error Object |
| Language Version: | ActionScript 3.0 |
| Runtime Versions: | 1.0, 9 |
On a desktop machine, memory allocation failures are rare unless an allocation request is extremely large. For example, a 32-bit Windows program can access only 2GB of address space, so a request for 10 billion bytes is impossible.
By default, Flash Player does not impose a limit on how much memory an ActionScript program can allocate.
See also
| Method | Defined By | ||
|---|---|---|---|
MemoryError(message:String = "") Creates a new MemoryError object. | MemoryError | ||
![]() | Returns the call stack for an error as a string at the time of the error's construction (for the debugger version
of Flash Player only). | Error | |
![]() | Indicates whether an object has a specified property defined. | Object | |
![]() | Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() | Indicates whether the specified property exists and is enumerable. | Object | |
![]() | Sets the availability of a dynamic property for loop operations. | Object | |
![]() | Returns the string "Error" by default or the value contained in Error.message property,
if defined. | Error | |
![]() | Returns the primitive value of the specified object. | Object | |
| MemoryError | () | Constructor |
public function MemoryError(message:String = "")| Language Version: | ActionScript 3.0 |
| Runtime Versions: | 1.0, 9 |
Creates a new MemoryError object.
Parametersmessage:String (default = "") — A string associated with the error object. |
package {
import flash.display.Sprite;
import flash.errors.MemoryError;
import flash.utils.setInterval;
public class MemoryErrorExample extends Sprite {
private var crashingStr:String;
private var intervalId:Number;
public function MemoryErrorExample() {
crashingStr = "abcdefghijklmnopqrstuvwxyz";
intervalId = setInterval(exhaustMemory, 50);
}
public function exhaustMemory():void {
try {
crashingStr += crashingStr;
}
catch(e:MemoryError) {
trace(e);
}
}
}
}