Efficient Memory Management for Modelica Simulations

Authors Michele Scuttari , Nicola Camillucci , Daniele Cattaneo , Federico Terraneo , Giovanni Agosta

Thumbnail PDF


  • Filesize: 0.56 MB
  • 13 pages

Document Identifiers

Author Details

Michele Scuttari
  • Politecnico di Milano, Italy
Nicola Camillucci
  • Politecnico di Milano, Italy
Daniele Cattaneo
  • Politecnico di Milano, Italy
Federico Terraneo
  • Politecnico di Milano, Italy
Giovanni Agosta
  • Politecnico di Milano, Italy

Cite AsGet BibTex

Michele Scuttari, Nicola Camillucci, Daniele Cattaneo, Federico Terraneo, and Giovanni Agosta. Efficient Memory Management for Modelica Simulations. In 13th Workshop on Parallel Programming and Run-Time Management Techniques for Many-Core Architectures and 11th Workshop on Design Tools and Architectures for Multicore Embedded Computing Platforms (PARMA-DITAM 2022). Open Access Series in Informatics (OASIcs), Volume 100, pp. 7:1-7:13, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2022)


The ever increasing usage of simulations in order to produce digital twins of physical systems led to the creation of specialized equation-based modeling languages such as Modelica. However, compilers of such languages often generate code that exploits the garbage collection memory management paradigm, which introduces significant runtime overhead. In this paper we explain how to improve the memory management approach of the automatically generated simulation code. This is achieved by addressing two different aspects. One regards the reduction of the heap memory usage, which is obtained by modifying functions whose resulting arrays could instead be allocated on the stack by the caller. The other aspect regards the possibility of avoiding garbage collection altogether by performing all memory lifetime tracking statically. We implement our approach in a prototype Modelica compiler, achieving an improvement of the memory management overhead of over 10 times compared to a garbage collected solution, and an improvement of 56 times compared to the production-grade compiler OpenModelica.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Compilers
  • Computing methodologies → Modeling and simulation
  • Modelica
  • modeling & simulation
  • memory management
  • garbage collection


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Giovanni Agosta, Emanuele Baldino, Francesco Casella, Stefano Cherubin, Alberto Leva, and Federico Terraneo. Towards a high-performance modelica compiler. In Proceedings of the 13th International Modelica Conference, pages 313-320, 2019. URL: https://doi.org/10.3384/ecp19157313.
  2. Giovanni Agosta, Francesco Casella, Stefano Cherubin, Alberto Leva, and Federico Terraneo. Towards a benchmark suite for high-performance Modelica compilers. In 9th International Workshop on Equation-Based Object-Oriented Modeling Languages and Tools, November 2019. URL: https://doi.org/10.1145/3365984.3365988.
  3. Johan Åkesson, Magnus Gäfvert, and Hubertus Tummescheit. Jmodelica - an open source platform for optimization of modelica models. In 6th Vienna International Conference on Mathematical Modelling, 2009. Google Scholar
  4. Mats Andersson. An object-oriented language for model representation. In Proc. 2nd IEEE Control Systems Society Workshop on Computer-Aided Control System Design, pages 8-15, Tampa, FL, USA, 1989. Google Scholar
  5. Barbara Rita Barricelli, Elena Casiraghi, and Daniela Fogli. A survey on digital twin: Definitions, characteristics, applications, and design implications. IEEE Access, 7:167653-167671, 2019. URL: https://doi.org/10.1109/ACCESS.2019.2953499.
  6. Paul I. Barton and Constantinos C. Pantelides. Modeling of combined discrete/continuous processes. AIChE journal, 40(6):966-979, 1994. Google Scholar
  7. Francesco Casella. Simulation of large-scale models in modelica: State of the art and future perspectives. In 11th Int'l Modelica Conference, pages 459-468, 2015. Google Scholar
  8. Francesco Casella, Martin Otter, Katrin Proelss, Christoph Richter, and Hubertus Tummescheit. The modelica fluid and media library for modeling of incompressible and compressible thermo-fluid pipe networks. In Proceedings of the 5th international modelica conference, pages 631-640, 2006. Google Scholar
  9. Hilding Elmqvist. DYMOLA - a structured model language for large continuous systems. In Proc. Summer Computer Simulation Conference, Toronto, Canada, 1979. Google Scholar
  10. Peter Fritzson, Peter Aronsson, Adrian Pop, Hakan Lundvall, Kaj Nystrom, Levon Saldamli, David Broman, and Anders Sandholm. Openmodelica-a free open-source environment for system modeling, simulation, and teaching. In 2006 IEEE Conf on Computer Aided Control System Design, 2006 IEEE Int'l Conf on Control Applications, 2006 IEEE Int'l Sym on Intelligent Control, pages 1588-1595. IEEE, 2006. Google Scholar
  11. Peter Fritzson, Adrian Pop, Adeel Asghar, Bernhard Bachmann, Willi Braun, Robert Braun, Lena Buffoni, Francesco Casella, Rodrigo Castro, Alejandro Danós, et al. The openmodelica integrated modeling, simulation and optimization environment. In Proceedings of the 1st American Modelica Conference, pages 207-220. Modelica Association, 2018. Google Scholar
  12. John B Kam and Jeffrey D Ullman. Global data flow analysis and iterative algorithms. Journal of the ACM (JACM), 23(1):158-171, 1976. Google Scholar
  13. Chris Lattner and Vikram Adve. Llvm: A compilation framework for lifelong program analysis & transformation. In International Symposium on Code Generation and Optimization, 2004. CGO 2004., pages 75-86. IEEE, 2004. Google Scholar
  14. Oliver Lenord, Martin Otter, Christoff Bürger, Michael Hussmann, Pierre Le Bihan, Jörg Niere, Andreas Pfeiffer, Robert Reicherdt, and Kai Werther. efmi: An open standard for physical models in embedded software. In Proceedings of 14th Modelica Conference, 2021. URL: https://doi.org/10.3384/ecp2118157.
  15. Kendrik Yan Hong Lim, Pai Zheng, and Chun-Hsien Chen. A state-of-the-art survey of digital twin: techniques, engineering product lifecycle management and business innovation perspectives. Journal of Intelligent Manufacturing, 31(6):1313-1337, 2020. Google Scholar
  16. Mengnan Liu, Shuiliang Fang, Huiyue Dong, and Cunzhi Xu. Review of digital twin about concepts, technologies, and industrial applications. Journal of Manufacturing Systems, 58:346-361, 2021. Digital Twin towards Smart Manufacturing and Industry 4.0. URL: https://doi.org/10.1016/j.jmsy.2020.06.017.
  17. Sven Erik Mattsson, Hilding Elmqvist, and Martin Otter. Physical system modeling with modelica. Control Engineering Practice, 6(4):501-510, 1998. Google Scholar
  18. Nicholas Nethercote and Julian Seward. Valgrind: a framework for heavyweight dynamic binary instrumentation. ACM Sigplan notices, 42(6):89-100, 2007. Google Scholar
  19. Arunkumar Palanisamy, Adrian Pop, Martin Sjölund, and Peter Fritzson. Modelica based parser generator with good error handling. In Proceedings of the 10th International Modelica Conference; March 10-12; 2014; Lund; Sweden. number 096, pages 567-575. Linköping University Electronic Press, 2014. Google Scholar
  20. Adrian Pop, Per Östlund, Francesco Casella, Martin Sjölund, Rüdiger Franke, et al. A new openmodelica compiler high performance frontend. In 13th International Modelica Conference, volume 157, pages 689-698, 2019. Google Scholar
  21. Martin Sjölund, Peter Fritzson, and Adrian Pop. Bootstrapping a modelica compiler aiming at modelica 4. In 8th Int'l Modelica Conference, Dresden, Germany, pages 510-521. Linköping University Electronic Press, 2011. Google Scholar
  22. The Mathworks, Inc. Simscape documentation. https://mathworks.com/help/physmod/simscape/, 2022 (latest version).
  23. John Tinnerholm. An llvm backend for the open modelica compiler, 2019. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail