Sganga61 Member Licensed User Longtime User Oct 13, 2020 #1 Hi I need to free memory to show a large number of images Here follow some samples I try to explain: Code: Copy For i = 1 To 100 PROTOCOL_FASE.Bitmap = LoadBitmapSample(Path , filename, 1360dip, 690dip) Next With the above code about after 10 load images (same image) the program crash due to end of memory Code: Copy For i = 1 To 100 PROTOCOL_FASE.RemoveView PANEL_PROTOCOL.addview(PROTOCOL_FASE,0dip,3dip,1360dip,690dip) PROTOCOL_FASE.Initialize("") PROTOCOL_FASE.Bitmap = LoadBitmapSample(Path, filename, 1360dip, 690dip) Next Same problem Code: Copy For i = 1 To 100 Dim LIMAGE As Bitmap LIMAGE.Initialize(Path, filename) PROTOCOL_FASE.Initialize("") PROTOCOL_FASE.Bitmap = LIMAGE Next Same problem There is a way to discard unused images, unload images or free up the memory? I need to show (sequentially) about 100 images of 500Kb each. Some suggestion?
Hi I need to free memory to show a large number of images Here follow some samples I try to explain: Code: Copy For i = 1 To 100 PROTOCOL_FASE.Bitmap = LoadBitmapSample(Path , filename, 1360dip, 690dip) Next With the above code about after 10 load images (same image) the program crash due to end of memory Code: Copy For i = 1 To 100 PROTOCOL_FASE.RemoveView PANEL_PROTOCOL.addview(PROTOCOL_FASE,0dip,3dip,1360dip,690dip) PROTOCOL_FASE.Initialize("") PROTOCOL_FASE.Bitmap = LoadBitmapSample(Path, filename, 1360dip, 690dip) Next Same problem Code: Copy For i = 1 To 100 Dim LIMAGE As Bitmap LIMAGE.Initialize(Path, filename) PROTOCOL_FASE.Initialize("") PROTOCOL_FASE.Bitmap = LIMAGE Next Same problem There is a way to discard unused images, unload images or free up the memory? I need to show (sequentially) about 100 images of 500Kb each. Some suggestion?
Erel B4X founder Staff member Licensed User Longtime User Oct 14, 2020 #2 1. The file size is (mostly) meaningless. The bitmap dimensions matters. 2. Unreferenced bitmaps are released automatically, however it will not happen immediately. 3. There is never a good reason to load 100 large images. You cannot show them at once anyway. Complicated example that shows an endless number of images: https://www.b4x.com/android/forum/threads/b4x-b4xpages-pleroma-mastodon-client.119426/#content Simpler example based on BitmapsAsync: https://www.b4x.com/android/forum/threads/b4x-bitmapsasync.119589/ Upvote 0
1. The file size is (mostly) meaningless. The bitmap dimensions matters. 2. Unreferenced bitmaps are released automatically, however it will not happen immediately. 3. There is never a good reason to load 100 large images. You cannot show them at once anyway. Complicated example that shows an endless number of images: https://www.b4x.com/android/forum/threads/b4x-b4xpages-pleroma-mastodon-client.119426/#content Simpler example based on BitmapsAsync: https://www.b4x.com/android/forum/threads/b4x-bitmapsasync.119589/
Sganga61 Member Licensed User Longtime User Oct 14, 2020 #3 Thank you Erel. My examples don't explain very well what I need: I need to show (sequentially 100 images). In the above examples the PROTOCOL_FASE is an imageview. What is the best solution to show (sequentially and every second) 100 images? Thanks again Upvote 0
Thank you Erel. My examples don't explain very well what I need: I need to show (sequentially 100 images). In the above examples the PROTOCOL_FASE is an imageview. What is the best solution to show (sequentially and every second) 100 images? Thanks again
Erel B4X founder Staff member Licensed User Longtime User Oct 14, 2020 #4 1. Nothing special just load the image right before you need to show it. 2. Use B4XImageView from XUI Views. Upvote 0
1. Nothing special just load the image right before you need to show it. 2. Use B4XImageView from XUI Views.
Sganga61 Member Licensed User Longtime User Oct 14, 2020 #5 But it is exactly what I do.... but after a lot of images I get a memory fail... I note that after about one minutes the memory is free by Android background service....but I can't wait this time. Upvote 0
But it is exactly what I do.... but after a lot of images I get a memory fail... I note that after about one minutes the memory is free by Android background service....but I can't wait this time.
Erel B4X founder Staff member Licensed User Longtime User Oct 14, 2020 #6 There isn't enough information to help you. How are you showing the images? Are you using CLV? Have you implemented lazy loading? It will not work without it. Upvote 0
There isn't enough information to help you. How are you showing the images? Are you using CLV? Have you implemented lazy loading? It will not work without it.