Hi. I have made a piece of test code, that you find here with an explanation of how I ran my test.
In summary: If I run the code, and benchmark the results it shows more memory allocation than I expect. If I then copy a certain piece of the code (redefining a function) to the REPL, and rerun my test it behaves as I expect (low memory allocation). I would be happy if someone could take a look at my code, and see what I have made wrong. Thanks for any help in advance.