Low Memory Available

I have memory stability problem and need to free up some more memory! I have // Commented out all "Serial.println" not in use and added the Serial.println(F("some text" )) were I could! But I still have over 77% used.

Can I put variable array's like " byte array1[26] = {}; " in PROGMEM and call it when needed? if so how do I do that?

Can I put variable array's like " byte array1[26] = {}; " in PROGMEM and call it when needed?

Yes, if the array is not written to. PROGMEM is read-only.

if so how do I do that?

RTFM?

Will that will not work then! It does get written to. Is there anything else I can do to reduce memory? What would be a safe % as far as memory?

Is there anything else I can do to reduce memory?

We’re supposed to know what you’ve already done? Where is your code?

chrisnet: I have memory stability problem ... But I still have over 77% used.

The value reported by the IDE is PROGMEM. It is not RAM. You can't have a "PROGMEM stability problem".

If you have a RAM problem, you're going to need to figure out what structures are consuming RAM an optmize them.

chrisnet: Is there anything else I can do to reduce memory?

Well based on the code you posted...

chrisnet: What would be a safe % as far as memory?

Again the amount of PROGMEM your program uses has nothing to do with "stability."

I have // Commented out all "Serial.println" not in use and added the Serial.println(F("some text" )) were I could! My code is 162,784 bytes! I did not think that anyone wanted to look at that much code!

The IDE says

Global variables use 6,335 bytes (77%) of dynamic memory, leaving 1,857 bytes for local variables. Maximum is 8,192 bytes.
Low memory available, stability problems may occur

Most issues I have found and fixed. I lust dont want to get back into more problems as I am not done with the program.

Right, that was added in the more recent release. Forgot about that.

Well, without seeing code, I'm not sure what people can offer other than "avoid the String object, use F() for all Serial.print()s, and put anything you can in PROGMEM."

Ok I did all of that and I made sure that I used the smallest data type capable of holding the information in all variables! I was hoping that I could do something else! Do you have any idea what size of memory I should try to keep it under?

Well depending on your [u]code[/u], you can fill the RAM and be perfectly stable.

I'm done answering questions on this thread.

Thanks for your time!

chrisnet: I have memory stability problem and need to free up some more memory!

How do you know? If it is crashing, even with 23% free memory, this is pure guesswork isn't it?

I would be happy if I only had one byte of free memory, as long as I knew that byte wasn't going to get used. :)

Bear in mind calling functions uses memory (because the return address gets pushed onto the stack).

My code is 162,784 bytes! I did not think that anyone wanted to look at that much code!

I just skim for keywords. Like "String", "malloc" and:

int foo [500] [300];

Bear in mind calling functions uses memory (because the return address gets pushed onto the stack

I did not know that! But that makes since! And I do have a lot of functions, I guess that's where the memory is going! I'll have to look over the code and see which functions that I can combine.

Thanks

Well, you get it back when the function returns. And the return address is only two or maybe four bytes. Still, deeply nested functions could conceivably gobble some memory. And of course, local variables (declared inside the function) take memory too.

Hai
I have some memory problem in the program.I am attaching the problem and also the program.While running the code the ethernet sheild get stoped within 12 minutes.Pls help me to trouble shoot this.

low memory.txt (413 Bytes)

program.txt (3.54 KB)

Get all those constant strings out of RAM, then report back.

Application of the auto-format tool wouldn't go amiss before you re-post your code, preferably in code tags, and not as an attachment.

I assume you are using a Uno. If that is the case, and without going into the detail of the code, a look at just the list of libraries would suggest that your problem is that you are sending a boy on a man's job. You can verify this by checking the memory used when compiling. Clearly, it will be less than 32k, but anything over 29 - 30k is a pretty sure sign of impending doom.

If those are the signs, the solution is to get a Mega.

I also notice that you have the line Serial.println("error opening test.txt"); twice. That seems messy

I'd reclaim the 400-odd bytes of RAM I estimate are wasted in that sketch before thinking about a new board.

Who are you talking to? Because the thread was hijacked by @sruthy.

aarg: Who are you talking to? Because the thread was hijacked by @sruthy.

After more than eighteen months, it's more "nercro-ed" than "hijacked", so yes, I'm referring to the most recent sketch.