2024-04-23 12:35 AM
Gm,
I am creating a scrollable list of items, and we want have an image for each one of the items in the list, I have created a code that always prints 12 images depending on the scrollContainer.getScrolledY() value. This is for memory saving.
To display the image i use BMPFileLoader.cpp from the touchGFX documentation.
And i have created a 6MB cache in FrontedAplication.cpp which can print my image like 21 times.(I use the same image for debugging but later on they will have different images)
This is how I update the images:
I call lthis code every 50 ticks.
And everything works perfectly but once a amount of ticks has passed, this is what happens to the images:
They dissappear, and i don't know what is causing this. I'd like to debug or be able to see whats being stored in the cache or if clearCache() is really removing the images from the cache, but I have no way to do this right?
As I said before, this happens after an amount of ticks have happened as if i call this every 5 ticks for example, the crash happens much faster.
Solved! Go to Solution.
2024-05-14 01:26 AM
Hello @I_ve_got_a_problem ,
@JTP1 have mentioned to me that you are not closing your file after reading it.
I have tried to close it in the project you sent and it does solve the problem for me.
All I did was adding
fclose(f);
at the end of your createBitmap function.
I the solves your issue, I invite you to select this message as "best solution".
Regards,
2024-05-14 03:39 AM
Having to set the image size won't be a problem as the server will tell us data we need about it, this is working just fine, just out of curiosity how did you debug this so deeply? I mean as far as I know simulator can't be debugged, and even if I try to put a try{} surrounding the whole createBitmap() function it never gets to the catch, I don't know why but it directly crashes.
Thanks for the solution btw
2024-05-14 04:25 AM
How did you debug so deeply?
I just used prints. You can print stuff with the function touchgfx_printf(); which behave just like the regular printf. To use it, you need to #include <touchgfx/utils.hpp>.
I have issue with the size previously so I knew to check that.
But I think setting the size is not the correct approach. I don't know if you seem my last message about fclose(f);.
Closing your file after reading it seem to be the correct fix and is either way good practice.
I think this is the fix that other people could benefit from so it would be nice if you could test it and if it works for you select it as best answer so that other people encountering the same issue could find the correct fix quickly.
Regards,
2024-05-14 05:54 AM
You are right that did fix it, i left it running on my lunch time and got no crashes, thanks again.
2024-05-14 06:00 AM
My pleasure, I also learned something today! ;)