Memory allocation changes when redefining a function

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.

This comment to my own post is mostly for documentation. The unusual memory allocations seem to come from using optional keyword arguments. This seems not to be a problem in julia 0.5 but only in 0.6, and not under all circumstances. See and run the small code example here to check my results. I can open an issue on github if anyone feels that the problem is important enough. If inlining the functions with keyword arguments using @inline the problem also disappears.