Automatically control how many object pool

I have project that has been done without pooling system, now i want to implement pooling system,
basically i will Instantiate objects if the objects are not available in the pool and replace destroy with active false.
The problem is I don’t know and don’t want to know how much does the project will instantiate unique object and save it to the pooling system.
I want to make pooling system automatically control how many object pool still able to create before i really destroy them in mobile devices.
I mean if my game getting slow because too many object pool i want to start destroy.

You can keep create object until below are triggered.
I use both

fps counter and native memory warning

On Android and iOS if my frame rate fall down below 30 on mobile or if i’ve got memory warning from iOS or Android, it will auto reduce my object collection in the pooling system by destroying them.

I wish unity create have this memory warning API in the future so we don’t have to create plugin manually.
This also could be use to call garbage collection and unloadunusedasset before iOS kill your game.
See here for plugin reff


	public void onTrimMemory(int level)
		if(level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW){
			UnityPlayer.UnitySendMessage("DontDestroyObject", "CallBackFromAndroid", "OnTrimMemory");


- (void) applicationDidReceiveMemoryWarning:(UIApplication*)application
    [super applicationDidReceiveMemoryWarning:application];

UnitySendMessage(“GameObjectNameInTheInspector”, “DidReceiveMemoryWarning”,”");