# Using generated functions to preallocate memory?

**URL:** <https://discourse.julialang.org/t/using-generated-functions-to-preallocate-memory/23070>\
**Category:** Internals & Design\
**Created:** [April 12, 2019, 10:25am UTC](https://discourse.julialang.org/t/using-generated-functions-to-preallocate-memory/23070 "2019-04-12T10:25:30Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [April 12, 2019, 7:40pm UTC](https://discourse.julialang.org/t/using-generated-functions-to-preallocate-memory/23070/13 "2019-04-12T19:40:30Z")

</div>

I also use generated functions in [`Measurements.jl`](https://github.com/JuliaPhysics/Measurements.jl/blob/4c71c9d39285c435e23d68648a594d0583079307/src/Measurements.jl#L65-L66) to preallocate an empty structure, here is a related discussion: [Question about use of generated functions](https://discourse.julialang.org/t/question-about-use-of-generated-functions/3355). The utility of generated function compared to a constant is that I can preallocate the structure for any arbitrary type.

---

_[View the full topic](https://discourse.julialang.org/t/using-generated-functions-to-preallocate-memory/23070)._
