Simon, from what I see you are a researcher at university. I see you have access to Simulink Coder, but I am not sure about you have access to Embedded Coder. Embedded Coder might be what you are looking for.
Independently, code generated from Simulink certainly should have not memory leaks. You may want file a bug report with MathWorks Technical Support.