Go Down

Topic: The HATRED for String objects - "To String, or not to String" (Read 13 times) previous topic - next topic

GoForSmoke


For most cases this will result in no pointer change at all and a simple adjustment of the allocated length - usually out into free space in most use-cases on a small system like this.


Assuming the String is at the top of the heap in 'most cases'. Otherwise not.

Andy Brown, I think you will find that Nick knows more about the code than you credit. And he isn't given to make unfounded claims.

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

zoomkat

So is there anything in the external programming that can be done to free the no longer used allocated memory space?
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

retrolefty


So is there anything in the external programming that can be done to free the no longer used allocated memory space?


Perhaps enable the WDT, let if time out, and have the sketch start all over?  :D

zoomkat

Quote
Perhaps enable the WDT, let if time out, and have the sketch start all over? 


Close to what my magic 8-Ball suggested.  :)
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

Nick Gammon


Andy Brown, I think you will find that Nick knows more about the code than you credit. And he isn't given to make unfounded claims.


I don't have any argument with Andy. I think he has the fixed malloc/free library on his site anyway.

There is a bug in 'free' in the current Arduino library. I think we are all agreed on that. What Andy says about free spaces being combined by the library would almost certainly be correct. But the bug in question is something to do with the first (or last?) allocated block not being freed correctly, or something like that.

I have heard people say that, with the fixed free() installed, they can use String objects at some length with no problems, which supports what Andy says about the library combining unused blocks.

Go Up