Memory usage on String/const *char in Particle cloud functions parameters?

Hi all, I came across this post from Scruffr:

from the memory consumption standpoint, is there a clear benefit to using the const *char option instead of the “default” String option?

The reason for that comment was to “relieve” the previous poster of the headache they feared with heaving to convert back and fro between String and const char*.

In that case it had nothing to do with memory management since the Particle.function() logic internally works with String either way.
However, when declaring the parameter as const char* the implementation of said function can use char* everywhere without ever needing to convert from String to const char* as that will be done implicitly when calling the function.

1 Like

Does the above mean that both options are equivalent to memory usage (since Particle.function() is using String either way)? Thanks again.

However, you can stay clear of String inside the function and thus avoid additional memory impact potentially incurred by temporary String variables therein.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.