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

Time:08-31

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?

CodePudding user response:

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.

  • Related