+ Start a Discussion

How to get around Apex class file size limits

I am creating a moderate class which is about 38,769 bytes in Eclipse but when I try to save it back to salesforce i get the message:
"Save error: The total size of apex code in this application after removing comments exceeds the maxiumum character size of 1000000".
I don't see how this can be since i clear have less than 1,000,000 bytes.  Any ideas? 
The maximum amount of code used by all Apex scripts in an organization is 1 MB.  Its not your class - rather, its the total amount of code that you've added to your organization.

I would recommend adding the
isTest annotation to your test classes:

Classes defined with the isTest annotation do not count against your organization limit of 1 MB.

Thanks very much.  That's exactly what I needed to know...


I represent a large client running into this issue. If test classes are excluded and it's still an issue can the limit be lifted upon request if proven warranted?

Any help is appreciated.

I would have your client log a ticket with salesforce.com support to see if they can increase this limit.
Were you able to get past this error ? :( ... did Salesforce allowed an exemption of any sort?

SFDC can raise this limit.  It's a black tab feature that requires opening a support ticket and waiting for them to review your org to see why you're hitting the limit.

They'll require basic housekeeping such as the previously mentioned @isTest being used in test classes and testMethod for test methods.  After the review if you're still hitting/approaching the limit they will raise it for you.  I have a client who is well on their way to hitting 3M in apex.  We've had to raise their limit twice to accomodate the code.