Huge memory allocations using execute()


I have a software that embeds cling the following way:

create on the heap an instance of an interpreter

load some files and libraries at initialisation time

call an interpreted function using a single execute() call to draw OpenGL code at every frame

I get a lot of allocations every frame (growing up at a rate of 20Mb/sec)

If I execute the same OpenGL code without interpreting (compiling the code within the software and calling it directly instead of using cling) I do not get the same amount of memory allocations.

Is this behaviour normal?


Shouldn’t happen. Can you send me a massif output? valgrind --tool=massif … Which version (e.g. commit hash) of cling do you use exactly?

As a workaround you can always ask cling to give you a C-style function pointer, and if your function is really the same throughout, just keep on calling that function pointer. Use DeclareCFunction(), RunFunction() for that.



I have been using Instruments on OS X for measuring memory usage.

I downloaded the latest release valgrind source code but it does not compile on OS X 10.10.

Can I send a report with Instruments?


I have seen bogus numbers from instruments. Can you run your code on Linux, and then use valgrind?