# Debugging memory issues

**URL:** <https://discuss.ocaml.org/t/debugging-memory-issues/3223>\
**Category:** Learning\
**Created:** [January 24, 2019, 1:52am UTC](https://discuss.ocaml.org/t/debugging-memory-issues/3223 "2019-01-24T01:52:02Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![sean](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sean/32/981_2.png) [@sean](https://discuss.ocaml.org/u/sean)\
**Post date:** [January 24, 2019, 1:52am UTC](https://discuss.ocaml.org/t/debugging-memory-issues/3223/1 "2019-01-24T01:52:03Z")

</div>

Hey all,

I’m working on a [new compiler/transpiler](https://github.com/stan-dev/stanc3) written in OCaml and we’ve (unfortunately?) been using the Format library to emit the code that we’re generating. Today I’m just starting to run it on some huge test programs and finding that it’s taking up dozens of GB of memory pretty quickly and totally swamping the machine only a little ways into the program. I tried debugging with `ocamldebug` but I can’t find any specific code that’s repeating too much or anything like that - it just seems like something invisible is happening and my number one suspect is that it’s the building up of these long Format strings (with nested “%a” compositional formatting). But I’d like to figure out for sure so I don’t waste time switching away from the Format library or something if it’s an unrelated issue.

Any help appreciated! Thanks 🙂

---

_[View the full topic](https://discuss.ocaml.org/t/debugging-memory-issues/3223)._
