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
Kittu KoppulaKittu Koppula 

'System.LimitException: Too many code statements: 200001 ' exception in Winter 14

Hi,

One of my Sandbox instance is upgraded to Winter 14. As per Winter 14 release notes, 'Too many code statements' limitation is removed.

But still am getting the exception.

Dhaval PanchalDhaval Panchal
Might be you need to change version of your apex class.
Kittu KoppulaKittu Koppula
Hi Dhaval,

Thanks for your reply. I changed the version to 29.0. But still am getting the same exception.

Thanks,
Venkata Krishna Koppula.
Satish_SFDCSatish_SFDC
This limit has been removed starting Winter 14. So if you still get this error, i would advise you create a case so this can be investigated.

Regards,
Satish Kumar
Satish_SFDCSatish_SFDC
Let me also investigate this in the meantime. I will get back.

Regards,
Satish Kumar
Kittu KoppulaKittu Koppula
I raised a Case with Salesforce support. Waiting for their reply. Will update once i get response.
EJWEJW

We ran into this issue as well, and just to do a sanity check I ran the following code in the debug console:

 

Integer counter = 0;

for ( Integer x = 0; x < 500000; x++ )
    counter++;

 That code produces the same error.

EJWEJW

FYI, got this response from SFDC support:

 

"I had discussed this issue with R&D where they replied that the "Too many code statements" limit is still on until they work out the "CPU time limit error" that has started occurring in Winter'14."

 

Thanks,

sfdcchampionssfdcchampions

Hi 

 

EJWEJW

Unfortunately they didn't give any ETA.  It's pretty rare when I can get an ETA so I don't really bother asking anymore.  :)  This is a rather major apex feature for Winter '14 so I'm assuming it'll be fixed by then but who knows.  For now it's just business as usual with the limits.

 

Really looking forward to this though, it'll be so nice to write actual maintainable code for complex projects instead of using workarounds and hacks to stay within the limits as I have to currently.  Many of those workarounds/hacks are actually more CPU intensive than doing things the proper way, so rewriting that code will probably give us a speed increase as well.

 

I probably have comments similar to this in 20-30 different places in my code: "God help me for doing this, it's terrible but we have to stay within the script limits."

 

The biggest change will be initializing properties in classes.  Currently if I'm passing in initial values to a constructor I assign them to all the properties in a single line of code, as otherwise I get a script statement hit for each assignment and for the declaration of the properties when the class is instantiated.  So I have classes that look like the following so I don't blow a ton of statements when I need to create 50 of them for some reason:

 

public class SomeClass {
	public String someVar1, someVar2, someVar3;
	public Integer int1, int2, int3;

	public SomeClass( String someVar1, String someVar3, Integer int1, Integer int2, Integer int3 )
	{
		// God help me for doing this.
		Boolean horriBad = ( ( this.someVar1 = someVar1 ) == null && false )
			|| ( ( this.someVar2 = someVar2 ) == null && false )
			|| ( ( this.someVar3 = someVar3 ) == null && false )
			|| ( ( this.int1 = int1 ) == null && false )
			|| ( ( this.int2 = int2 ) == null && false )
			|| ( ( this.int3 = int3 ) == null && false );
	}
}

 

Memory optimizations have been a headache as well, 6MB is painful when working with multiple rows using long text fields or attachments.  Ok, done rambling.