From ffdc465085c4e60c21b81ce029bc40f654033b27 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 21 Jan 2019 20:02:41 -0500 Subject: [PATCH] adds u3m_reclaim to clear persistent caches in vere --- include/noun/manage.h | 5 +++++ noun/manage.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/noun/manage.h b/include/noun/manage.h index 16fa82847..e8212efbf 100644 --- a/include/noun/manage.h +++ b/include/noun/manage.h @@ -125,3 +125,8 @@ */ void u3m_wall(u3_noun wol); + + /* u3m_reclaim: clear persistent caches to reclaim memory + */ + void + u3m_reclaim(void); diff --git a/noun/manage.c b/noun/manage.c index 9cc10773d..1841e4da7 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -1723,3 +1723,33 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, u3n_ream(); } } + +/* u3m_reclaim: clear persistent caches to reclaim memory +*/ +void +u3m_reclaim(void) +{ + // clear the memoization cache + // + u3h_free(u3R->cax.har_p); + u3R->cax.har_p = u3h_new(); + + // clear the bytecode cache + // + u3h_free(u3R->byc.har_p); + u3R->byc.har_p = u3h_new(); + + // clear the jet battery hash cache + // + u3h_free(u3R->jed.bas_p); + u3R->jed.bas_p = u3h_new(); + + // clear the jet hank cache + // + u3h_free(u3R->jed.han_p); + u3R->jed.han_p = u3h_new(); + + // clear the u3v_wish cache + u3z(u3A->yot); + u3A->yot = u3_nul; +}