开发者

Creating two or more singleton

开发者 https://www.devze.com 2023-03-12 04:44 出处:网络
I created 3 singleton classes for making it easy to access the objects and methods. I used a class for having url connection and save the data into some objects while other开发者_开发问答 singleton sa

I created 3 singleton classes for making it easy to access the objects and methods. I used a class for having url connection and save the data into some objects while other开发者_开发问答 singleton saves to the core data model and the other to synchronize and get values from those classes and store in some objects.

Is it bad programming pattern to have more singleton and does it have some issues with memory management ? Singleton are created once and never released until the app is shut so it may have some memory overloading problem.


Although you could use any number of singleton that required to fit in your requirement but i feel,there must be some limitation on that when they handle large chunk of data, like in your case ,All your singleton class are just service provider to your applications components and handle large chunk of data So you need to do good memory management streagy , like identifying the data which you not required for long , temporary data, and the stored data which your apps require at any time. and release them properly on time.

0

精彩评论

暂无评论...
验证码 换一张
取 消