Background
I'm learning how to use Renderscript, and I found this part in the docs:
http://developer.android.com/guide/topics/renderscript/advanced.html#mem-allocation
To support this memory allocation system, there are a set of APIs that allow the Android VM to allocate memory and offer similar functionality to a malloc call.
...
To better understand how these classes work, it is useful to think of them in relation to a simple malloc call that can look like this:
array = (int *)malloc(sizeof(int)*10);
The problem
I'm failing to understand something: What if I want to allocate memory within RS itself?
For example, suppose I need to have a calculation that requires a lot of memory compared to the input and output, can I do it all inside RS itself, instead of from Java?
What I've tried
I can't even succeed in creating a new array, even if it's in constant size:
static int array[1024*1024*100] ; //this is ok
void init() {
rsDebug("init called. array check:",(int)(*array));
array[0] = 2; // this is not ok
rsDebug("init called. array check:",(int)(*array));
}
And all I get for this code is this error:
Error:Execution failed for task ':app:compileDebugRenderscript'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\android\Sdk\build-tools\22.0.1\llvm-rs-cc.exe'' finished with non-zero exit value -1073741819
The questions
Is it possible to dynamically allocate memory on RS ? Instead of doing so from Java ?
If it's possible, is this memory a part of the heap, or a part of the global, available RAM of the device? Will it be auto-GC-ed when the Renderscript object on Java gets GC-ed ?
What about all the static variables that are set inside RS ? Are they a part of the heap?
Would all kinds of allocations of RS be automatically freed like on GC , once the Renderscript object on Java gets GC-ed ?
I ask this because of some weird explanations on the docs.