Skip to content

Fix atom leak #37

Merged
merged 1 commit into from Jan 31, 2012

3 participants

@Vagabond

I adapted this patch from Jason Wagner which removes the code creating dynamic atoms in the parse_transform. Without this patch, adding 1 line to a file and recompiling it would bloat the atom table (because the generated atoms included line numbers). A simple test with lager_test_backend saw the difference between memory(atom_used) grow by 585 bytes (after the file was already loaded):

12> X = memory(atom_used).
673491
13> l(lager_test_backend).
{module,lager_test_backend}
14> memory(atom_used) - X.
585

After the patch, there was no atom table growth.

@nialscorva nialscorva Moved a lot of the AST in lager_transform into a function to make thi…
…ngs easier to read and modify

Additional changes and formatting by Andrew Thompson
2f9b793
@Vagabond Vagabond commented on the diff Jan 27, 2012
src/lager_transform.erl
end,
- %% a case to check the mochiglobal 'loglevel' key against the
- %% message we're trying to log
- LevelVar = list_to_atom("Level" ++ atom_to_list(get(module)) ++
- integer_to_list(Line)),
@Vagabond
Vagabond added a note Jan 27, 2012

These are the terrible dynamic atoms in question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@russelldb
Basho Technologies member

So, if I add funs to lager_test_backend, recompile it and then reload it, the atom memory usage does grow. Should it? If I just add whitespace, or io:formats to existing function bodies, and recompile and reload the behaviour is as you describe above.

If that is what you expect, then I'm +1 on this.

@Vagabond

I actually think I was leaking atoms in the compiler, not at runtime. However, Jon says since it improves the code readability to merge it anyway.

@Vagabond Vagabond merged commit 18f1806 into master Jan 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.