Waldemar Lima Well-Known Member Licensed User Longtime User Jul 13, 2021 #1 High ram usage with ImageView, the more ImageView, the more ram is "swallowed" Why does this happen? I'm just doing a sketch Last edited: Jul 13, 2021
High ram usage with ImageView, the more ImageView, the more ram is "swallowed" Why does this happen? I'm just doing a sketch
Waldemar Lima Well-Known Member Licensed User Longtime User Jul 13, 2021 #2 Fixed high ram consumption by converting by deleting the imageview, and replacing them with " Label " Upvote 0
Fixed high ram consumption by converting by deleting the imageview, and replacing them with " Label "
Erel B4X founder Staff member Licensed User Longtime User Jul 14, 2021 #3 1. The high ram usage isn't related directly to the ImageViews. 2. Unless the process runs out of available memory then you should ignore it. The garbage collector will allocate RAM when available. If it does crash then you should debug your program and see where it leaks memory. Tip: only do it in release mode. Upvote 0
1. The high ram usage isn't related directly to the ImageViews. 2. Unless the process runs out of available memory then you should ignore it. The garbage collector will allocate RAM when available. If it does crash then you should debug your program and see where it leaks memory. Tip: only do it in release mode.
Waldemar Lima Well-Known Member Licensed User Longtime User Jul 14, 2021 #4 what's strange is that I didn't do anything different in both : I created an ImageView / Label in DesignerEditor -> Imported the image in the Files tab -> in Background Drawable I set BitmapDrawable an image and run it in Release Upvote 0
what's strange is that I didn't do anything different in both : I created an ImageView / Label in DesignerEditor -> Imported the image in the Files tab -> in Background Drawable I set BitmapDrawable an image and run it in Release
Waldemar Lima Well-Known Member Licensed User Longtime User Jul 14, 2021 #5 I did some tests here, after I restart the PC, the overuse of memory by java no longer occurs... Upvote 0
agraham Expert Licensed User Longtime User Jul 14, 2021 #6 One classic cause of this apparent excess memory use is that images comprise a small managed (Java) object and a larger unmanaged native image. The Java garbage collector doesn't know about the large native object and so doesn't see the need to run a garbage collection when a reference goes out of scope so the memory use builds up until a collection is made. Don't obsess over this, it will get collected at some point. If you do actually end up with out of memory problems by using lots of large images then you can call a garbage collection yourself but this is not really advised except in extremis. Garbage collection | B4X Programming Forum Upvote 0
One classic cause of this apparent excess memory use is that images comprise a small managed (Java) object and a larger unmanaged native image. The Java garbage collector doesn't know about the large native object and so doesn't see the need to run a garbage collection when a reference goes out of scope so the memory use builds up until a collection is made. Don't obsess over this, it will get collected at some point. If you do actually end up with out of memory problems by using lots of large images then you can call a garbage collection yourself but this is not really advised except in extremis. Garbage collection | B4X Programming Forum
KMatle Expert Licensed User Longtime User Jul 15, 2021 #7 We run several servers at work which run Java (via TomCat). Java is known to allocate huge amounts of RAM. Never had problems (although it's "scary" at the first look). Upvote 0
We run several servers at work which run Java (via TomCat). Java is known to allocate huge amounts of RAM. Never had problems (although it's "scary" at the first look).