 I am Rajesh and today I am going to use some of the problems in the how to handle low memory scenarios in android, yeah coming to the agenda initially I will cover how the process management takes place in android and then even though linex android is just the same linex kernel but there are some few differences among between android memory management and linex memory management but today I am not going to tell all the details but I am going to cover some of the details yeah what do you mean by low memory scenario yeah generally they will call low memory scenario is nothing but if the free ram in the if the free memory in the ram is less than some threshold they will call it as a low memory and what they will do in the low memory scenarios that low memory killer and this activity manager service in the low memory scenarios they will kill some of the applications and we will see what kind of applications will be killed and what kind of applications will be killed in the later slides but the system does not know whether this kind of applications are interesting to the user and can we skip these applications it simply kills based upon some of the coding on static rules. So we have to improve the functionality such that it should not kill applications which are interesting to the users and if you manage the low memory scenarios in an effective manner we can improve the speed of the device we can see in the later slides how can we achieve all these factors yeah now coming to the process management in android in simply in the process in the android it classifies all the applications into different groups and I will explain all the groups what they mean foreground means the applications which are user currently interacting they all applications comes under foreground group and visible are nothing but the applications which are in the back but they are supporting to the foreground applications they comes under this visible process and now coming to the service process yeah the apps which are running on the background using that service component I hope all of you know that android application has four components activity services and content providers and broadcast receivers. So the apps which are running on the background using the service components they will come under this category and the apps which are reside on the back they will comes under the hidden that means they are not using service component and they are using some other components yeah now coming to the content provider content providers are nothing but the they will provide some structural data and other applications can access this data such type of applications comes under this content provider group and now coming to the empty processes this is the new thing in the android because in general whenever the in the line x if the user terminated from any application or any process all the details belong to that process are completely removed from the RAM but in android it does not do like that it keeps all the code belongs to that application inside the RAM itself we will see why it keeps and what are the advantages and what are the disadvantages in the next slides okay I hope remember this this group empty process empty process are nothing but I am repeating once again in general even though user terminated that app the code belongs to that application still remain inside the RAM okay yeah basically this snapshot I took from the aakash tablet here I am listing different applications which are reside inside the RAM and yeah the apps which are rounded in this red color they are foreground applications and the applications which are rounded in this blue color they are the empty applications and in this sky blue color they are content provider application so I want to show through this image in the RAM we have different kinds of applications like empty foreground the content providers and so most of the times our RAM was filled with so many applications but you can if you clearly see the image there are many empty applications in this image because our RAM always filled with so many empty applications like this is 1, 2, 3, 4 so many empty applications are there so we will see next what are the advantages and disadvantages yeah one of the advantages of the empty applications is yeah we can ever reduce the load time that means in general whenever user clicks on an application it checks whether this application is available inside the RAM if that is not available inside the RAM it has to load that app from the SD card into the RAM and it has to start so that is the process if you keep the applications inside the RAM that means even though user terminated that application if you keep that app inside the RAM if you revisit the same application in the future we do not need to load the same app from the SD card into the RAM so we can avoid this load time such that we can improve the speed that means most of the times you may felt when you restarted your tablet if you click on any application it will take too much time to load in the first time because it has to load from the SD card to RAM and then it has to start if the if you close that same app and if you reopen it will come immediately the reason is it load it still reside inside the RAM so such that if you keep the applications inside the RAM we can avoid this load time and also we can reduce the power consumption that means it took and it took lot of power to load the application from SD card into the RAM so we can skip these two this is one of these are the some of the advantages of the empty applications now we will see what are the disadvantages of the empty applications if you keep inside the RAM for example let us assume that your RAM was filled with so many empty applications and now we are going to choose another application which is not reside inside your RAM so now what kernel has to do it has to kill some of the applications and make sure that free memory is available and free the some of the memory and then it has to start load the app from the SD card into the RAM and start so that means here one more lag time is coming that means killing the applications takes some time so we are adding some extra time also so if you have so many empty applications in our RAM we will increase the loading time for the apps which are not there in the RAM so these are the disadvantages such that so from we have advantages and disadvantages through this empty applications so we have to maintain some balance such that how many applications we have to keep and what kind of applications we have to keep and we should not kill in the low memory scenarios the apps which are interested to user so we will see how can we do that yeah I hope all of you know the how the booting takes place in the Android in general during the booting times system service used to start all the services like telephone manager service and activity manager service and other services we will see some of the drawbacks through this telephone manager and the activity manager services in the later slides yeah this is the snapshot I took from the Aakash tablet here I want to show that some of the applications which are reside inside the RAM which are belong to the making phone calls or contacts or some of the applications I hope all of you know that our Aakash tablet it doesn't have any feature to support the making phone calls and sending SMS but still and loads the applications which are supporting for making phone calls and sending SMS so such kind of applications are loaded into the RAM and they are residing inside the RAM you can see this rounded applications which are reside in the RAM and this is application which is holds the contacts and this is the application for making some third-party application for calls and this is the application which is responsible for making the call so if our RAM with was filled with such kind of applications even though our hardware doesn't support any telephone where sim they are simply residing without use without is less so if you identify such kind of applications and remove from the RAM we can use that memory for other applications here nearly these applications are occupying 10 to 15 MB so if you free that memory we can use the same memory for other applications so we can how can we solve this this problem simply just we have to modify during the boot time that if system service has to check whether the hardware support to hardware is supported to do phone calls or not if the hardware is exist then only load the such all such kind of applications if the hardware doesn't support you don't need to load such kind of applications yeah now coming to the activity manager service yeah this is the service which is reside inside the framework layer of the Android I hope all of you remember the layers of the Android and it contains four layers this activity manager service which I reside at the framework layer and this is the intermediate between the user and the background layers that means it receives the inputs from the user and executes the command that means whenever you click an app or whenever you want to close an app all the request goes to this service and it will do some of the it launches the applications and updates the status and kills the applications based upon the user request so this is the central coordinator that means intermediate between the user and the background layers so we will see some of the how it works and what are the some different problems in this activity manager service yeah now I'm going to show one more snapshot that means this is the snapshot I took immediately when the boot booting was over in the from August tablet but I found some interesting facts like that when during the boot time this activity manager service loads some of the applications into the RAM which for example I will show some of the applications like I installed a lot of applications on my tablet and for these applications like the board blue vessel and the asteroid and some next slide from manager and there are a lot of applications I have installed very long back and I have used only one or twice that's nearly one month backer surround but the problem is whenever the booting is completed that this activity manager loads all such kind of applications I will tell you in the next slide what kind of applications it will load immediately during the boot time so I found that I never used such applications I used only once very long back so even though I'm not using this kind of applications right now but they are all still loading into the RAM and they are residing in the RAM so if you avoid such kind of applications nearly all these applications are occupying 3.2 MB in RAM so if you avoid such kind of applications we can save some n number of applications into some 3.6 RAM so we can free some of the RAM and we can use the same RAM for the other applications yeah now I will tell during the boot time activity manager service loads some of the applications which have some features like this if any application has the persistent equal to true it loads that application into the RAM during the boot time persistent in the means this application should be reside inside the RAM always so if any developer can put this kind of in code in his application such kind of applications will always reside in the RAM so even though you are interacting or does not interacting with those applications such kind of applications are always reside in the RAM and one more is Android provides one feature for us we can start our application immediately when the boot was completed if any user uses this facility and he wants to start his application immediately when the booting was over such kind of applications also loaded into the RAM and like that there are some so some rules are there so activity managers simply check for this kind of applications if there any applications they are loaded into the RAM I want to say that this activity manager simply loads the applications based upon the some static rules it never checks whether these applications are user is interacting or these kind of applications are user frequently interacting it never checks so I want to say that we can improve that is its functionality such that we have to keep the empty application only the user frequently interacting and we can remove the applications when we can remove the application which are not interacted by the user like the application that I have showed in the previous snapshots so we can provide this facility simply like that we can maintain the log history of the user with what kind of application he is interacting and so we can identify some we can preload them into the RAM immediately when the booting was over one of the advantage of this preloading is we are loading the applications which are interesting to the user before he wants to interact so such that we can avoid the loading time when he wants to interact such kind of application I had showed you what do you mean load time in the first slides so if you load the applications which are interested to the user before he interacts so we can avoid load time such that we can improve some little bit speed of the phone and one more is if you increase the priority of the applications which is user interacting frequently such that we can skip such kind of applications from killing in low-memory scenarios so we can improve the functionality of this activity manager service such that identify his interesting applications and reload them and increase the priorities such that we can skip such applications killing in the low-memory scenarios yeah now coming to the low-memory killer still now you have I had given details on activity manager service and now I am going to give details on low-memory killer which is reside in the kernel layer of the Android and its functionality is to simply kill the applications in low-memory scenarios I will explain how it works right now and all these values I took from this Akash tablet with RAM size 512 mv I hope all of you remembered Android classifies process into different groups and these are the priority values for each group lesser the priority means higher the higher higher highest its priority that means foreground has the highest priority and empty has the least priority yeah now I will explain how it works if the free memory in the RAM is less than 10 mb then kill applications which are belongs to empty group and whose priority value is greater than or equal to 15 and remember one thing the apps belongs to this group and whose priority value is less than 15 they will not be killed okay have you I hope on you understood this like that the free memory is less than 8 mb and the pro applications which are belongs to this group and whose priority value is greater than or equal to 9 they will be killed so like that it follows all the way so but some of the advantages and disadvantages through this killer I will tell in the next slides but observe this thresholds mean free thresholds that means these are very Android never the tablet which have this values it will never kill applications it will never kill any empty application still the free memory is less than 10 mb for example let us take a scenario when if the free memory is nearly around 10 to 12 to 15 mb then this time you are going to select some of the application some bigger publication which is not there in the RAM let us example certain temple runner anything it will nearly consumes 25 mb that temple run game so this time this kernel has to kill the applications and load that app from the SD card into the RAM and it has to start so it takes long time to kill applications and load so based upon this thresholds we can decide that means how many applications we have to kill and how aggressively we can kill and how many empty applications we can keep so maintaining some default thresholds which will provide kill only some limited number of applications and do not kill aggressively such that you have to tune such a manner we should not improve increase the lagging time and we should not kill too many applications yeah now coming to the some of the advantages and disadvantages of the low memory low mean free threshold low mean free that means these thresholds if they are low what are the advantages and disadvantages the main advantage is if you have these thresholds very low we can have so many empty applications reside in the RAM so such that the response time for accessing the such applications is very less and one more is and but the disadvantages is the apps which are not reside inside the RAM if the user wants to load them such then such times we have to kill some applications and load them it is a few that means it is good for the application which are reside in the RAM and it is bad for the application which are not there in the RAM so such that we have to keep these thresholds in a manner we have in a manner such that we can keep the applications which are interacted to the interested to the user and this is the same opposite to the what are the disadvantages if you have the high mean free threshold same will come like opposition to this and now coming to the some of the problems in the low memory killer the main most of the Android users complaining that the default mean free thresholds they are getting they are not getting any good performance at that time they are having some slow in their phones they change their values they are getting some good speed in their phone so such that we have to tune the system such that it can identify the default values in such a manner for giving good performance and also this static mean free thresholds keeping same threshold all the times is may not be good we have to this is the some theoretical assumption and if you do some practical work and we can prove it may be useful yeah this is one more ongoing project compressed catch this is nothing but our Android does not have any strap space so the reason is that is the limitation of flash memory I am not giving all the details but this project concentration on implementing the swap space inside the RAM that means or whenever the user it wants to swap a press page it simply compress that page and swap that page into the this swap space and whenever it wants to access that page and decompress and load so like that this process this project go and if anyone have any wants to more details on this project you can contact later and so finally I want to say something we have to keep and manage our RAM in such a manner such that we have to keep the applications which are interesting to the user only and we can we can skip the some of the applications like applications which are applicable for making phone calls and the application which is never interacted by the user if you keep such kind of applications we are uselessly putting them in the RAM if you remove those applications and make free the RAM and we can use the same RAM for other applications also so such that we can decrease the load time and we can improve the speed of the phone these are the references thank you