Increasing memory usage after repeated margins calls in Stata
0 reputation · 20 Sept 2021, 04:49 UTC
Goal: Determine whether the memory increase observed after repeated calls to the margins command in Stata reflects a true leak or expected caching of intermediate results, and whether clearing that memory requires a manual Mata workspace reset.
Constraints: Reports differ across Stata versions; Stata 18 changed internal memory‑management for margins, but certain options such as at() or contrast() may still leave temporary Mata objects, and clear all does not affect Mata workspace.
Questions: Does the margins command in Stata 18 retain temporary Mata objects after each call when using at() or contrast() options? Is the observed memory growth after repeated margins calls attributable to caching rather than a leak, and does executing mata drop _all fully release that memory? Are there any documented settings or commands that guarantee release of margins‑related temporaries without ending the session?