In Salesforce Lightning, We use @AuraEnabled annotation for method in server side apex controller.All the @AuraEnabled Methods are static. But Static methods loads in memory first and could take lot of heap space.Whats the reason that Salesforce has kept these methods as static. because having lot of static methods will take more heap space. Any special reason behind this.
@AuraEnabled methods are
static for the same reason that Visualforce remoting methods are
static: because those architectures don't maintain any state on the server. State would be represented as an object instance to which a member function is bound.
static functions also don't maintain state outside of the bounds of a transaction since they aren't bound to an object instance, they are the required Apex structure for making such server calls.
But Static methods loads in memory first and could take lot of heap space
having lot of static methods will take more heap space
I'm not sure where these assumptions are coming from but I think there's a core misunderstanding of what
static methods do. I would be happy to discuss further if you expand on this.