Post

Replies

Boosts

Views

Activity

Reply to How do I limit C program memory allocation to 1 virtual page on macOS Sonoma?
Yeah this is kind of what I was getting as well when I was running Malloc implementations I could get addresses and for the most part it seemed that the malloc allocations the size would be a contiguous range of virtual memory for each malloc but the space between each malloc was vastly different. As for the goal of the benchmark it was looking at different implementations of malloc such as stdlib.h malloc, tcmalloc, and mimalloc... seeing if there was a difference in space efficiency of these approaches. I was pretty sure that maybe what I was looking for was unfeasible or at least from the way I was approaching it this post was mostly me trying to see if I was missing something. Here is a snippet of how the test looked where report memory would check to see if there was a bounds violation and then turn on a flag i had while (1) { //here would be like where I would replace the implementation int *ptr = (int *)malloc(size); // i read somewhere that sometimes this will get put off somewhere if i did not actively allocate it so i did this to be safe for (int i = 0; i < size / sizeof(int); i++) { ptr[i] = i; fprintf(fptr2,"J%d:%p\n",i,&ptr[i]); } /*report memory checks if the amount of memory allocations has reached a limit of memory the process could have or violate the bound */ report_memory(); if(flag==1){ break; } // Log successful allocation fprintf(fptr, "%zu\n", allocation_count); allocation_count++; }
Topic: Programming Languages SubTopic: General Tags:
Mar ’25
Reply to How do I limit C program memory allocation to 1 virtual page on macOS Sonoma?
This is just an experiment and specifically for the process I am using, not for all processes on my system. I am the one invoking the malloc calls as well. The goal is just too see how many mallocs of x size can be fit into a range of virtual memory addresses. It is mostly looking to see how much fragmentation is between each malloc call because if you have a fixed range of virtual addresses that this specific process has access to we can see how many mallocs can be called before it goes out of bounds.
Topic: Programming Languages SubTopic: General Tags:
Mar ’25