Hi, I'm trying to implement pointer instead of using stack memory. My program works well using stack memory, but as my program grows, I need to use heap memory instead
In my effort to use dynamic allocation, I got the error
05-08 12:49:25.101: A/libc(12515): @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree
05-08 12:49:25.101: A/libc(12515): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
I tried to figure out, but could not make it out.
Here is my case.
I created a for loop to generate some data, and store those data into vector array. by using vector array, I manipulated the the order of element and then store those data into dynamic float array.
Previously, using stack array
|
float myData[100000]; // Succesful, but the size is limited.
|
Using dynamic array
1 2 3 4 5 6 7 8 9 10 11
|
float *myData;
myData = new (nothrow) float[myVectorarray.size()];
if(myData == 0){
cout<<"failed to allocate memory"<<endl;
}
for(int i = 0 ; i <myVectorarray.size() ;i++){
myData[i] = myVectorarray.at(i);
}
|
I also add to free the memory.
Questions:
1. What are the errors trying to say?
2. I realise using stack array provide faster processing data then dynamic array. But I did not know which provide the biggest space to store the data?
3. Is there anything else I have to take into account when using dynamic allocation memory?
Thanks