I put this up for discussion as I'm not overly happy with it - but it seems to work.
I have a large B4J app that runs on Windows 10. The app does some serious image processing and is fed new images at a rapid rate of knots. The app can handle multiple images in parallel - currently set to 4.
There are no #VirtualMachineArgs settings - all defaults.
When it is going flat out I notice that the memory usage of the app (as shown by Windows Task Manager) slowly but surely rises until it gets to about 2.5GB when the various steps in the processing start shedding (I have lots of error detection in each step).
This results in the images currently being processed not being processed - which I have a recovery mechanism for.
Ultimately it falls over and is automatically restarted.
I obviously started looking for memory leaks etc to no avail.
In quiet desperation, I ported this:
https://www.b4x.com/android/forum/threads/solved-how-to-force-a-garbage-collection.68588/
And copied agraham's Threading library from B4A\Additional Libraries to B4J\Additional Libraries - which agraham says should work - and it seems to.
After each image is processed I now force a garbage collection - and lo and behold the memory usage of the app (as shown by Windows Task Manager) settles at about 1.2-1.6GB for multiple thousands of images processed. With no obvious detrimental side effects.
Any suggestions/comments?
I have a large B4J app that runs on Windows 10. The app does some serious image processing and is fed new images at a rapid rate of knots. The app can handle multiple images in parallel - currently set to 4.
There are no #VirtualMachineArgs settings - all defaults.
When it is going flat out I notice that the memory usage of the app (as shown by Windows Task Manager) slowly but surely rises until it gets to about 2.5GB when the various steps in the processing start shedding (I have lots of error detection in each step).
This results in the images currently being processed not being processed - which I have a recovery mechanism for.
Ultimately it falls over and is automatically restarted.
I obviously started looking for memory leaks etc to no avail.
In quiet desperation, I ported this:
https://www.b4x.com/android/forum/threads/solved-how-to-force-a-garbage-collection.68588/
And copied agraham's Threading library from B4A\Additional Libraries to B4J\Additional Libraries - which agraham says should work - and it seems to.
After each image is processed I now force a garbage collection - and lo and behold the memory usage of the app (as shown by Windows Task Manager) settles at about 1.2-1.6GB for multiple thousands of images processed. With no obvious detrimental side effects.
Any suggestions/comments?