The limit on the amount of characters you can have in Apex is 3,000,000. I understand that comments and test classes do not count towards this limit. Another developer just asked me if the space character counts and I could not answer with certainty. I hope that someone out there can tell me that they do not count against the character limit.
1 Answer
A quick test would suggest that they do...
Here is a simple class in my DE
and the code usage
If I add loads of characters, the usage goes up..
when I removed them, it went back down, now I added loads of white space, and the usage climbed again:
And this is chaining lots of spaces together, so I would say that lots of individual spaces in real code will behave the same way..!
It even counts spaces at the end of a line, as you can see here:
It does also count the spaces at the start of a line (the indentation)
BUT
It does not appear to count spaces in lines containing nothing but spaces though!
-
-
2I did not... but just for you @sfdcfox please see the edit ;) Commented May 29, 2014 at 15:33
-
2and an interesting revelation in the last line of the answer regarding lines containing nothing BUT spaces.. Commented May 29, 2014 at 15:37
-
Thank you for taking the time to figure that out, Simon. We try to keep our code formatted for readability but I guess we'll just need to keep it ugly as we get close to our character limit. Commented May 30, 2014 at 17:10
-
Tabs also counts 1 towards character limits, so it could be useful to use tabs instead of 4 spaces.– AequitasCommented Jan 24, 2018 at 23:26