Android Question What really gets stored on map?

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
See a code like this:
B4X:
Dim imgMap As Map
imgMap.Initialize
Dim i As Bitmap=LoadBitmap(File.DirAssets,"square.jpg")
For x=0 To 100
      imgMap.Put(x,i)
 Next

How does this really work?
What is stored on the map? Yes a object!

But a reference?
What is the impact on memory?

If another code is used:
B4X:
Dim imgMap2 As Map
imgMap2.Initialize
Dim i As Bitmap=LoadBitmap(File.DirAssets,"square.jpg")
For x=0 To 100
      imgMap2.Put(x,i)
 Next

then double the memory will be consumed?

Thanks for explanations.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The memory impact of the first code snippet is approximately the memory required to hold the bitmap (once). The map and ints overhead is small.
i = a reference to a bitmap instance.

then double the memory will be consumed?
Yes. There is no relation between the two bitmap instances.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…