How do i put apps on sleep while my game is running in an Android Device. I m a Game Developer (intermediate Level). And i Wanna know the Can i put apps of phone running in background to sleep to free some ram and make my game run on 1 gb of phone smoothly (Android 9).
The OS on android devices handles this automatically when there is a need for more memory.
Specifically, what you are referring to sleep is moving apps to a standby state where they unload all data caches. After a second pass they will automatically save their data and state so they can shut down all tasks except background listeners and reopen later.
You have no control over this mechanism beyond taking up memory.
If your application is slowing down to declare more memory, try to load as much of the assets and metadata on initial scene load instead of in real time during gameplay. This should resolve most of your issues issues regarding memory heap footprint growth.
Any temporary variable (such as incrementing counters on loops) that will not last longer than the time in the function that creates it should be declared TLAB as to not be allocated from the main heap. This will further reduce memory heap growth.