in reply to Calling a C function using malloc() in a XS

Does
void do_simulation() { struct s* m; m = (struct s*)malloc(10000000 * sizeof(struct s)); free(m); m = (struct s*)malloc(10000000 * sizeof(struct s)); free(m); }
use more memory than
void do_simulation() { struct s* m = (struct s*)malloc(10000000 * sizeof(struct s)); free(m); }

It could be that the memory is being pout back into Perl's free memory pool and you just don't realize it.