I tell you my question. I have a simple program in C, I am working with linux Mint. The only thing he does is ask for memory until he can not ask for more. Here I put the code:
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("Iniciando creacion de matrices...\n");
double *p;
int i=1;
int cuenta=0;
long int total;
//printf("%lu",sizeof(double));
while(i){
p=malloc(10000*40000*sizeof(double));
cuenta++;
if(p==NULL){
printf("ERROR %d \n",cuenta);
break;
}else{
printf("CORRECTO %d \n",cuenta);
}
}
total=(long int)10000*40000*cuenta;
printf("%ld\n",total);
printf("Listo\n");
return 0;
}
I execute it again and again. According to my interpretation, since the memory is never released, it will be occupied and the next execution could not be made the memory allocation because I would have already assigned the memory in the previous execution and it would still be occupied. But this is not the case, I can execute it and execute it, and the value of the variable account is always the same: that is, it always makes around 43,980 assignments.
Well this code is just a test of a doubt that came to me when doing large memory allocations. But my curiosity can basically be found in the code.
Thanks for your help.