function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gregsgregs 

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? 
tmatthiesentmatthiesen
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:
http://www.salesforce.com/us/developer/docs/apexcode/index_CSH.htm#apex_classes_annotation.htm

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

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

Hi,

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.

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

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.

 

JT