macro called in a loop to generate static objects uses a lot of memory