# Memory allocation changes when redefining a function

**URL:** <https://discourse.julialang.org/t/memory-allocation-changes-when-redefining-a-function/4803>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 12, 2017, 12:29pm UTC](https://discourse.julialang.org/t/memory-allocation-changes-when-redefining-a-function/4803 "2017-07-12T12:29:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmgnve](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmgnve/32/1906_2.png) [@jmgnve](https://discourse.julialang.org/u/jmgnve)\
**Post date:** [July 12, 2017, 12:29pm UTC](https://discourse.julialang.org/t/memory-allocation-changes-when-redefining-a-function/4803/1 "2017-07-12T12:29:05Z")

</div>

Hi. I have made a piece of test code, that you find [here](https://gist.github.com/jmgnve/4875a2a7eb8677256105531812c2aee0) 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.

---

<div class="post-metadata">

**Author:** ![jmgnve](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmgnve/32/1906_2.png) [@jmgnve](https://discourse.julialang.org/u/jmgnve)\
**Post date:** [July 13, 2017, 2:23pm UTC](https://discourse.julialang.org/t/memory-allocation-changes-when-redefining-a-function/4803/2 "2017-07-13T14:23:17Z")

</div>

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](https://gist.github.com/jmgnve/ad2c932d9e5662285b44e18bbf285aaa) 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.
