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
gsarguccigsargucci 

Class loading overhead

Hi,

 

I'm hoping someone can offer some insights about class loading and object instantiation overhead in Apex.  Based on what I've seen in the docs, it appears that classes are loaded for each request context (which, for example, allows you to use static variables across different invocations in the same request).

 

Are classes really loaded for each request or are they cached?  How much overhead is associated with class creation in Apex.

 

For example, if I wanted to have a class of string constants, like this:

 

class MyStrings

{

  public static String STR_HELLO = "Hello";

  public static String STR_WORLD = "world";

}

 

and then access these strings from multiple other classes, like MyStrings.STR_HELLO, how much overhead would I be introducing, vs. just hard-coding the string ?

 

Is this described somewhere?  In general, is there any kind of a lower-level whitepaper or Apex architecture document that is available to shed some light on something like this?

 

Thanks in advance,

 

Alex

 

 

gsarguccigsargucci

Hi,

 

Sorry to be a pest--but I'd really like to understand this.  Can anyone provide an insight or point me at some relevant developer documentation?

 

Thank you in advance!