Why does the heap increase and then decrease after a certain level and then increase again? In linux os
When i study os, and memory structure, i found some strange address increase...
the program is simple, just recursive call for stack and heap increasing.
void recursive(int count){
long stack;
long* heap;
heap = (long*)malloc(sizeof(long)*100000000000);
heap = (long*)malloc(sizeof(long)*100000);
if((long*)heap >= (long*)&stack){
printf("heap is contact with stack\n");
exit(1);
}
printf("%diteration \\ heap : %p || stack : %p\n",count, heap, &stack);
recursive(++count);
}