Shop OBEX P1 Docs P2 Docs Learn Events
Any method to estimate memory usage for a program? — Parallax Forums

Any method to estimate memory usage for a program?

WBA ConsultingWBA Consulting Posts: 2,935
edited 2009-04-07 01:32 in General Discussion
When I first tried merging the SHT11 demo code with the VMusic2 Datalogger code, I ran into a lot of "out of memory" errors. I eventually trimmed up my program by pulling out all of the humidity sections and even recycled some variables to share between the VMusic2 and SHT11 subroutines. I finished it off very lean and yet the memory map is rather full. code is in this thread: http://forums.parallax.com/showthread.php?p=792332

In the meantime, I've taken a look at some other programs posted recently on the forums and some seem to have many more variables in use than me so I was wondering about the errors I originally saw.

If I am planning to piece together a couple programs, how can I guesstimate whether or not I will have sufficient memory space?

thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andrew Williams
WBA Consulting
IT / Web / PCB / Audio
1136 x 835 - 134K

Comments

  • Mike2545Mike2545 Posts: 433
    edited 2009-04-07 00:28
    Experience.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • SRLMSRLM Posts: 5,045
    edited 2009-04-07 01:32
    You can use 'generic' variables for things like temporary values and counters. Instead of having:

    mainCounter VAR word
    servoCounter VAR word

    you can just use

    counter VAR word

    Another thing to do is to figure out the scope of each variable that you would like to use. I use scope in the C++/Java sense of the life of a variable. Anyway, figure out which variables are in which scope (a venn diagram type might help here) and discover which variables are in scopes that don't overlap. Those two variables can then share the same memory space, either by using the same name or aliasing.

    Edit: Here's a thread I had a while ago, and it may help you get some of those buffer bytes back.

    http://forums.parallax.com/showthread.php?p=741388

    Post Edited (SRLM) : 4/7/2009 1:41:36 AM GMT
Sign In or Register to comment.