Closed invpe closed 2 years ago
MY-BASIC uses a _mb_allocated
variable to count allocations in "my_basic.c", so that it could tell footprint with the MEM
command. But it doesn't know allocations outside the core.
I suggest to use similar method in your native program, e.g. write dedicated allocate/free functions to manage all the memory operations. Moreover, you can also consider using a memory pool lib, which often offers more than allocation count in practice.
@paladin-t thanks, i was looking for a function that will return memory allocation of mybasic. This is to see the memory footprint of the script before calling any dispose/close functions of the interpreter.
Something along these lines:
iRetCode = mb_run(bas, true);
// Grab memory consumption before closing things
iMemAllocated = mb_mem(bas);
printf("Memory consumed by mybasic %ib\n",iMemAllocated);
mb_close(&bas);
mb_dispose();
Ah, sry I didn't get that.
Closing this.
Having
PRINT MEM
in the script file working, is there any way to obtain the same information in my native application by calling a function of MyBasic lib ?