Hi Babak:
Long time without talking!
I think I have found a memory problem with TDPFUIImageView.
Each time you assign a new bitmap to it, the RAM memory is decreased and it is never released, even if you do a DisposeOf().
So, eventually, you get a crash (tested in real devices) with the out of memory error.
I prepared a sample where you can see it.
It has 3 forms, the main is a selector with the Firemonkey and the DPF options. With the firemonkey component TImage you can assign a new bitmap anytime, however, with DPF the memory leak appears with 15-20 assignments.
Greetings!
Just press the "Fill Chart" button in both forms (the firemonkey and the dpf one) and you can see it by yourself.
Hi Diego
How did you compile this example with TChart on iOS !?
So that I know the iOS not have a chart component.
Please tell me more about it.
Regards
Hi Babak, they are the Steema Charting components included in Firemonkey plattform for XE4 and XE5. I don´t know if they are included in all RAD Studio versions.
Since they are not native... I managed to capture their frame with Makescreenshot and then load the image into a native UIImage. (The posted source shows how to do this)
I tried to load the images in several ways (with SetImage, Bitmap directly, etc)...
Hi Diego
Can you reproduce this bug with another sample without chart ?
Thanks.
Regards
Sure Babak.
I have removed the chart.
The bigger and complex the bitmap is, the sooner it will crash the application.
With this sample in an iPad 2 takes about 35-40 taps to crash. If you have a device with more RAM, it will take longer.
In simulator it doesn´t crash (I guess it is because it has much more RAM than a real device)
You can use instruments to check how fast the RAM is decreased with TDPFUIImageView bitmat assignment, while with Firemonkey TImage it works OK.
If you have cydia installed, I recommend you to install the free tool: StatusModifier, which allows you to see the free ram in status bar. This way you can see it directly in your device.
Thanks for your support!
Hi Diego
Fixed.
Please download last source [code]
Thank you for your feedback.
Regards
Related
Code: code
Hi Babak:
Thanks for the help!
Anyways, it seems there is still a problem when you do a "DisposeOf" in a TDPFUIImageView.
I have prepared the same demo, but this time, the TDPFImageView is created and destroyed in runtime.
With this situation, the memory leak appears again. Maybe I am not freeing the component correctly...
I tried to clearimage before destroying it, but it didn´t help.
Thanks in advance!
Hi again Babak:
I think I have found the solution.
As you already did in the procedure DoBitmapChanged, I added the line
to the destructor TDPFImageView.Destroy
like this:
There is still a small memory leak if you create a lot of images (12 or so) with big bitmaps assigned to them. Anyways, I think it won´t be a problem and I'll try to find the solution on my own.
Thanks again Babak!
Last edit: Diego 2014-03-16
Hi Diego
Don't add this line inside Destroy section, this work for you only if you set BitMap image in others this cause crash your app!
I changed some codes for fix leak,
Download last source code and test it again please.
Regards
Hi Babak:
It is working perfectly.
Thanks a lot!
By the way, you forgot the {IFDEF IOS} in var declaration of DoBitmapChanged.
Greetings!