I have a callback for getting an image from a 3rd party library. I can get it back in either a byte[] or a bitmap. Should I favor one or the other for memory purposes or something?
p
Paul Woitaschek
09/24/2023, 11:24 AM
I don't have a qualified answer but there were some topics regarding native memory not counting towards the jvm memory pool
c
Colton Idle
09/24/2023, 5:25 PM
Are either of those allocated in the native heap space?
r
Robert Williams
09/25/2023, 9:28 AM
Well assuming the byte[] is JPG, PNG etc it'll be a lot smaller than an ARGB 888 Bitmap
But this doesn't matter if you just want to render it and you're going to turn it straight into a Bitmap anyway (assuming you don't have any extra information or requirements that the library doesn't have)
So I'd say only use byte[] if you don't actually want a Bitmap (obviously) or if you think you can do the Bitmap conversion better than the library (unlikely but depends on your use case and how customisable the library output is)
c
Colton Idle
09/28/2023, 7:26 AM
Interesting. That's super helpful. Thanks robert! In my case... I was basically just going to render it anyway. and so. i guess grabbing a byte[] and converting to a bitmap doesn't make sense if the 3rd party can give me a bitmap instead. cheers