Announcement

Collapse
No announcement yet.

Memory problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Memory problem

    Hi everyone.

    I have uLCD43DCT and I've been working on the "SmartHome" project. The program that I'm still working on is pretty big.
    In FLASH BANK 0 I have boot menu, and then the desktop od my "SmartHome" interface (lcd). When I go to settings menu, I actually go to the FLASH BANK 1.
    Here I have again some menus - there comes a problem... I have a menu, where some variables are read from uSD. Then I call FLASH BANK 2 and pass 47 variables (which were previously read), then 9 icons are shown, and after that the program returns in FLASH BANK 1.

    THE PROBLEM is that when I go from one FLASH BANK to another some memory is used, but I don't know how to release it when the program returns from then FLASH BANK. Every time I go to FLASH BANK 2 and back there's ~2KB less memory.
    I was trying all sorts of code but I was unsuccessful! I tried mem_Free(ALL); which did free the memory (to 32KB), but after that the program crashed (sometimes restarted, sometimes just black screen)...

    Also I'd like to use file_LoadFunction, but how could I pass variables to the function?

    Please help me, I really need to fix this problem.



    Thank you for the answers

  • #2
    You mem_Free() pointers, normally these would be the pointers returned from mem_Alloc(), but file_loadFunction() and file_LoadImageControl() also allocate memory which needs to be freed this way when no longer required. This is all mentioned in the Internal functions manual.

    When memory is freed correctly the amount of memory available after returning from a bank should be the same as when it was called.

    There is a mem_Free(ALL) variant, but it should be used with extreme caution, as it will often free up things that are still in use.

    But I believe you have been told all of that, so Perhaps you need to post your code from that bank if you can't figure out what isn't being freed.

    As for passing variables to a function, try this

    Code:
        var parms[2] ;
        parms[0] := 1 ; // number of arguments
        parms[1] := hndl ; // first argument
        funcHndl(parms) ;
    Mark

    Comment

    Working...
    X