You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I have found a memory leak in clara when calling mk-session. I have been trying to find a memory leak in one of our services. I eventually found that the leak was from mk-session. This service creates lots of rules dynamically so initially I assumed it was that. I saw the :cache option in mk-session and thought that we were probably caching all those dynamically created rules, however turning off the cache did not help. I eventually created this minimal code to reproduce the leak. With cache false this leaks, with cache true it doesn't, but when adding in dynamically created rules the cache true also leaks, even after calling clear-session-cache!
@zan-xhipe if you have cache set to false then the rules will be recompiled every time, compiling rules is a CPU and memory intensive process, so every time you run this piece of code the clojure compiler is evaling the rules provided. The caching strategy used by clara currently is also very simple, it simply holds an atom with a map of productions to session, I highly recommend wrapping your own caching strategy in front of this if you want to have better control over it. The root of your problem in particular may be that your service creates rules dynamically so the productions are different every time you call mk-session, so having your own caching strategy in front of it to determine if you can re-use the session may be your only solution.
I think I have found a memory leak in clara when calling
mk-session
. I have been trying to find a memory leak in one of our services. I eventually found that the leak was from mk-session. This service creates lots of rules dynamically so initially I assumed it was that. I saw the:cache
option in mk-session and thought that we were probably caching all those dynamically created rules, however turning off the cache did not help. I eventually created this minimal code to reproduce the leak. With cache false this leaks, with cache true it doesn't, but when adding in dynamically created rules the cache true also leaks, even after callingclear-session-cache!
The text was updated successfully, but these errors were encountered: