Hi:
Is it any malloc problem with L5.4.70-2.3.0 SDK?
I am runing L5.4.70-2.3.0_images_MX8MQEVK.zip program on imx8mq-evk development board.
After enter file system, I can get total and free memory size by free command.
when I try to use malloc to get the maximum memory,the maxinum memory is bigger then system free memory size.
It also has the probem on the LF_v5.4.y-1.0.0_images_MX8MQEVK.zip.But it does not appear on the L4.14.98_2.0.0_ga_images_MX8MQEVK.zip version.
How can i fix this problem?
as the picture shows:
mem_tests code:
#include<stdio.h>
#include<stdlib.h>
size_t maximum=0;
int main(int argc,char *argv[])
{
void * block;
void * tmpblock;
size_t blocksize[]={1024*1024, 1024, 1};
int i,count;
for(i=0;i<3;i++){
for(count=1;;count++){
block = malloc(maximum+blocksize[i]*count);
if(block){
tmpblock = block;
maximum += blocksize[i]*count;
free(block);
}else{
break;
}
}
}
printf("maximum malloc size = %lf GB\n",maximum*1.0 / 1024.0 / 1024.0 / 1024.0);
printf("the address is %x\n",tmpblock);
printf("the address end is %x\n", tmpblock + maximum);
}
Solved! Go to Solution.