cancel
Showing results for 
Search instead for 
Did you mean: 

Cache memory seems to crash?

I_ve_got_a_problem
Associate III

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_ve_got_a_problem_0-1713857106438.png

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:

I_ve_got_a_problem_1-1713857222208.png

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.

 

 

14 REPLIES 14
GaetanGodart
ST Employee

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,

Gaetan Godart
Software engineer at ST (TouchGFX)

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

GaetanGodart
ST Employee

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,

Gaetan Godart
Software engineer at ST (TouchGFX)

You are right that did fix it, i left it running on my lunch time and got no crashes, thanks again.

GaetanGodart
ST Employee

My pleasure, I also learned something today! 😉

Gaetan Godart
Software engineer at ST (TouchGFX)