user19878941
user19878941

Reputation:

Why do we make a Singleton Class for Retrofit Client? What happens if we don't?

I have been working on android for some time and i wondered today that :

Why do we make a Singleton Class for Retrofit Client?

What happens if we don't?

Upvotes: 0

Views: 107

Answers (1)

Karan Mehta
Karan Mehta

Reputation: 1541

It is very simple,

Singleton class is used for this, so that only one object can be created at a time so this helps us in memory management.

If you don't make a class singleton then multiple instances will be created and if you don't trash those objects even by mistake then it will hold a lot of memory which is not good.

Upvotes: 1

Related Questions