Eme Fibonacci Well-Known Member Licensed User Longtime User Dec 24, 2018 #1 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.
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 Dec 24, 2018 #2 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. Eme Fibonacci said: then double the memory will be consumed? Click to expand... Yes. There is no relation between the two bitmap instances. Upvote 0
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. Eme Fibonacci said: then double the memory will be consumed? Click to expand... Yes. There is no relation between the two bitmap instances.