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
ethan huntethan hunt 

Performance Impact Or Memory Management Impact

Hi All,

The question might sound silly. Its a generic question that I want to ask.

If I instatiate a object for Ex - Employee emp = new Employee(); multiple times with the same instance variable name emp in different method, wht will be the impact.

Will it be on Heap Size or Performance.

Regards
Vinita_SFDCVinita_SFDC
Hello,

It should not impact heap size or performance if you are declaring a variable 10 times in a class but as per basic programming practice you can declare it just once.

If you wish to understand heap size then please refer following blog:

http://blog.jeffdouglas.com/2010/08/16/managing-the-heap-in-salesforce-com/
SRKSRK

Hay Hi

i i belive declaring a variable in apex class  impact heap size , because what ever you have declare in class it will take some memory sapce at runtime so i belive  that declaring mulitple variable  in a class will impact heap size of class

if you declaring an integer varibale it will take 2 btyes in memory 
if y declare 10 integer varibale it will take 2*10 btyes in memory