Shop OBEX P1 Docs P2 Docs Learn Events
SimpleIDE C beginners question. What's eating all my hub ram? — Parallax Forums

SimpleIDE C beginners question. What's eating all my hub ram?

Alex.StanfieldAlex.Stanfield Posts: 198
edited 2015-03-10 10:20 in Propeller 1
Hi, how do I get a memory usage listing when compiling with SimpleIDE C. I'm using CMM and with a very simple program all available memory gets consumed very easily.

Thanks
Alex

Comments

  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2015-03-09 19:55
    Ok, I found it myself.

    Just right click on the main .c file and select "Show map file" (compiles and gives the addresses and sizes of code and data)

    Alex
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-09 20:09
    Hi, how do I get a memory usage listing when compiling with SimpleIDE C. I'm using CMM and with a very simple program all available memory gets consumed very easily.

    Thanks
    Alex

    I'm not aware of such a tool.

    Here's some common causes:
    * printf - use printi from the Simple package when possible (or print if you need floating point support)
    * any use of floating point variables
    * many of the functions in the math library (libm.a/math.h)
    * Using C++ and accidentally including something from the standard library (exceptions, for instance)
    * malloc & free take a lot of space
    * SD card usage is quite heavy (i.e.: sd_mount)

    If you post your code, I (and many others) would be happy to take a look
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-09 20:09
    I'm not aware of such a tool.

    I'm not aware of a lot of things :(
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2015-03-10 04:22
    I'm not aware of such a tool.

    Here's some common causes:
    * printf - use printi from the Simple package when possible (or print if you need floating point support)
    * any use of floating point variables
    * many of the functions in the math library (libm.a/math.h)
    * Using C++ and accidentally including something from the standard library (exceptions, for instance)
    * malloc & free take a lot of space
    * SD card usage is quite heavy (i.e.: sd_mount)

    If you post your code, I (and many others) would be happy to take a look

    I'm sorry I haven't explained myself quite well. I just needed the map file to see how much memory I was using up and with what part of the code.

    BTW: I noticed that just including a file in the project manager gets the whole code linked even if there is no calling to any code in that file. Is there a way to avoid this other than excluding the file? Doesn't the linker sort out the code needed ?

    Alex
  • trancefreaktrancefreak Posts: 186
    edited 2015-03-10 04:30
    I'm not very familiar with SimpleIDE but I think there is a PRUNE checkbox somewhere in the project view under the compiler/linker tab.
    If you use that, pruning will be enabled which will remove unused functions.
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2015-03-10 04:35
    I'm not very familiar with SimpleIDE but I think there is a PRUNE checkbox somewhere in the project view under the compiler/linker tab.
    If you use that, pruning will be enabled which will remove unused functions.

    Correct! Thanks a lot!

    It's a checkbox in the "compiler" tab of the project manager.

    Alex
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2015-03-10 04:54
    Heater. wrote: »

    Thanks Heater, I have to re-read the SimpleIDE manual as this option wasn't there before (and I incorrectly assumed it was a natural part of the linking stage)

    Now I feel some relief, since my project was just starting and already memory exhausted.

    Is there a "tips" page for people familiar with the prop (SPIN/PASM) in transitioning to C (already knowing C/C++)?
    I mean, space saving, memory model choosing vs board type, multiple code instances, cog usage, etc, etc.

    Alex
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-10 06:06
    Is there a "tips" page for people familiar with the prop (SPIN/PASM) in transitioning to C (already knowing C/C++)?
    I mean, space saving, memory model choosing vs board type, multiple code instances, cog usage, etc, etc.

    If such a thing does not exist yet, or has not been compiled into a single, useful document/page, I'll create it in PropWare's documentation. This is definitely something the community needs.
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2015-03-10 07:21
    Great to hear that David. Thanks!

    Alex
  • SRLMSRLM Posts: 5,045
    edited 2015-03-10 08:54
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2015-03-10 10:20
    SRLM wrote: »

    That's a great page Cody, thanks a lot.

    Alex
Sign In or Register to comment.