-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Malloc RangeError: The specified range is invalid #38
Comments
Surely you can. On Jan 5, 2014, at 12:39 AM, trungnq97 [email protected] wrote:
|
This init function can guarantee that there is enough memory at the time it runs, but it cannot guarantee when this function exits. Is it correct? Can I put the pre-allocated memory code here (inside event ADDED_TO_STAGE)? addEventListener(Event.ADDED_TO_STAGE, init); and free it here (inside event REMOVED_FROM_STAGE)? addEventListener(Event.REMOVED_FROM_STAGE, cleanup); Many thanks, |
Don't understand what you are trying to say. |
I thought that when this If I CModule.malloc an amount of memory to preserve and I don't CModule.free it later, will this amount of memory be automatically released when user closes the page that contains my swf file? |
See that one byte allocation at the end? This will do the trick. |
Hi,
In side a loop, I use malloc to allocate some domain memory, and free it at the end of a loop. It works well for a while, then I received lots of RangeError.
RangeError: Error #1506: The specified range is invalid.
var pcmPtr:int = CModule.malloc(FRAME_SIZE_BYTE * CHANNEL);
I've seen this https://github.com/adobe-flash/crossbridge/wiki/Memory-Fragmentation, but I don't understand why malloc and free at the same time in init function.
protected function init(e:Event):void
{
var p:int=CModule.malloc(1024_1024_256);//pre-allocate a block domain memory, the size should be according to your project
if (!p)
throw(new Error("You have opened too many pages, close some of them or restart your browser!"));
CModule.malloc(1);//take up the domain memory
CModule.free(p);//release the pre-allocated memory so that it can be used for new C/C++ Object
...
}
Can preallocated memory fix RangeError issue?
Many thanks,
Trung
The text was updated successfully, but these errors were encountered: