Reputation: 672
It's maybe a stupid question for Java expert, but I need to understand.
I have a REST App with Controllers and Services. I use Java 8 and spring-boot.
When a request arrives, my service creates a new class instance, for example:
ContactDTO contactDTO = new ContactDTO();
If one day one hundred requests arrive in the same time, one hundred ContactDTO
class instance will be created. And more generally in a working day, a lot of instances are created. But what happens to those instances when the service has finished his job?
I know there was Garbage Collector
service in former Java versions, I don't know if it's still present in Java 8, 9, etc.
I read also tuto about @Transactional Spring annotation or Singleton in order to manage database access, but I'm a little confused with this.
What is the best way to manage these instances when they are no longer in use? And what effect about App performance if they are still active?
Upvotes: 0
Views: 101