Hi,
Yes, you need to release all the resources associated with the Session.
When you open a JCR session, there is a reference to the JCR repository object. Every session will consume some memory unless the logout() method is called explicitly. If you do not call this call and create lots of sessions, you risk an out-of-memory exception by your JVM, which terminates the AEM instance. A single leaked session isn’t a problem, but if you have hundreds or thousands of leaked sessions, it might turn into a problem.
NOTE: session.logout() releases all the resources associated with the Session. This method should be called when a Session is no longer needed.
Session (Content Repository for Java Technology API Version 2.0)
Please refer the below link for an example:
Adobe Experience Manager Help | Querying Adobe Experience Manager 6 data using the Sling getServiceR...
We hope this information helps!
Regards,
TechAspect Solutions