Mendix Garbage Collection and Memory Usage

1
Hello All!   I just had a question about how Mendix handles certain scenarios and how that may affect memory usage. We have a page in our app that upon a certain action will (among other things) make a REST call, and attach the returned set of objects to the page context (both are NPE). This is done because the call isn't super fast, and this set of objects is used in various different places on the page, so we're trying to avoid calling it more than once and instead retrieve via association.    From what I can tell, Mendix will retain page context objects in state for the last 5 pages? This means that once the user navigates away from this page, the page context AND all of the NPEs that were attached for the purpose of that page will be retained in memory.    The REST call that brings in these objects varies in size, but can get up to a few hundred records. We've also been having Memory Usage alerts and trying to pin down what might be causing it. Is it possible this sort of behavior combined with fact this is a relatively high traffic app could account for the high memory usage?    Any and all input is greatly appreciated!
asked
1 answers
0

Hi, this is a really good question! The memory usage gets overloaded pretty fast if you've got hundreds of NPE's being made, especially if you're waiting for the garbage collector to help you out. Have you got any sort of cleanup process in place for old data, or checks for existing data before doing the REST calls?

 

I'm running into a similar issue with high memory usage in an app that relies heavily on NPE's for showing data. The data is quickly out of date. I chose to use a root object to associate all of my data and use between different pages to avoid unnecessary REST calls.

 

I've tried to solve the memory issue by putting a use-by date on my root object. That way, if the object was made more than 5 minutes ago, I retrieve my data afresh so that the user isn't running too far behind. I think I've messed up, though, in that I didn't explicitly delete the old data, which means I'm relying on the good graces of the garbage collector. This is resulting in high memory usage, I think. I'm going to try to explicitly delete the objects when they're no longer relevant and see if this helps.

 

I'm curious about how you've worked with this issue, and I'll keep this updated if I have any really awesome results.

answered