How to clear variables for optimize memory , ram?

how to clear variables for optimize memory , ram ?

 String a = "test";
 and use a is completed!!!  for clear String ?

Do you want to clear it or remove it?

AFAIK, once you have a String created it doesn’t usually shrink again.

But assigning a (const char*)NULL should invalidate the String object and free the space.

Local (automatic) variables should get freed by the destructor as well.

In both cases heap fragmentation might still occure.

1 Like