In settings, applications we get to see how much memory the processes are using...
Now if I call my service from the activity the memory bumps up to 40+ Meg for the process, even though I've called finish () and swiped the activity making sure on destroy is fired....
Yet the memory usage for the process/service remains untouched!
Buy reboot it, using just the boot reciever to start my service shows it to only be using 2-3mb of memory, so that would imply something is very wrong
Anyone with a service can try this for themselves...
Hello,
Is it a Background Service or a Bound Service?
If it is a Background Service the Service is not destroyed if you close your app (activity). For me when I close the activity and destroy it, while leaving open the service, the memory usage of the process drops down.
If your activity has sent some data to the Service while it was open, then this data may take some memory on your smartphone because you have not cleared them in the Service. That's why when you do a fresh reboot your Service takes so few MB in RAM. Is there any communication between your Service and the activity? What variables are created at this communication in the service. There you should look.
Try assigning a null value to objects that you are no longer using in the Service, so garbage collector is easier to collect them and release memory. Furthermore, try to use shorts instead of ints (for example) where possible, remove any unused variables, make them private where this is possible.
Check here for more methods on how to reduce your memory of your app/service.
Also check out this. It helped me sort out some memory leaks in one of my apps. It REALLY helped me.
Related
Almost 6 MB of memory is being consumed overnight by the services.exe process while the PPC is docked. I start with about 9.5 MB of program memory and the next day I'm down to less than 3.5 MB. Other than Active Sync, nothing else is running.
I have the following processes active:
connmgr.exe
cprog.exe
device.exe
filesys.exe
gwes.exe
NK.EXE
PhotoContacts.exe
Pocket e-Sword.exe
rapiclnt
repllog.exe
sddaemon.exe
services.exe
shell32.exe
sktools.exe
srvtrust.exe
tmail.exe
VoiceCmd.exe
if you are using a cooked rom it could be because of a flaw in ur system
what rom u using
Kill the MS Voice Command. Turn it off from the start up and that alone will save you 5-7megs of ram. Make sure you disable the voice command at the starting item, and reboot. Weather services also seem drain out the memory on a long run.
ROM is latest stock version.
I'm not concerned with apps that are memory hogs, and I use Pocket Plus to fully close tasks.
I'm seeing growth of 6 MB overnight in the process services.exe. (See attached file for detailed list of processes and memory).
I'm starting to disable apps one at a time. I'm suspicious of ActiveSync so I'm starting with it first.
Photo Contacts ain't helping either. Unless they fixed it, I gave that one up last year because of a serious memory leak.
And if you're using MSVC you can definitely get rid of sddaemon.exe, that is for the Cyberon Voice Speed Dial & is what keeps putting the shorcut there in programs after you delete it.
Although the memory usage of shell32.exe is stable, it seems very large (over 10 MB). Is that normal?
basic questions/clarifications
if i may be allowed to ask a couple of questions/clarifications:
1. does it follow/mean that the larger the memory consumption the more it/app drains the battery?
2. does it follow/mean that the higher the cpu usage the more it/app drains the battery
3. what app is that shows the heap? i'm only using task manager 2.9 by dotfred, it shows the memory but no heap.
4. I don’t know if this is a good idea, but anyhow this also came, from a desperate search, for an application that determines, w/c program drains the battery more. Is it possible to log the CPU usage? configurable to log only at every 5,10, 20, 30 sec. I know this would also drain the battery more but if the log, logs the 3 tops most drainers then we could start from there. I hope I'm making myself clear. Thanks and more power…
i hope i'm not off topic..
bump
up up up ...
jmcbride is talking about the amount of allocated memory increasing overnight, rather than the battery consumption. The heap is the list of currently-unused memory locations. When a program needs additional memory, it asks the system for a block of memory of a particular size, and this memory is allocated from the heap. When the program is through using this memory, it should then release the memory back to the heap. The operating system is supposed to combine adjacent free memory blocks, if possible, so that as much memory as possible is available as a contiguous block. This procedure is known as garbage collection. If a program loses track of what memory it is no longer using, without releasing it back to the operating system, the amount of free memory gradually gets less and less. This is known as a memory leak. One application that I have noticed is prone to memory leaks is Mobipocket Reader. If I leave it running for hours, I eventually have to reboot my phone in order to get back the free memory and be able to run commands.
I am using aserg windows mobile 6.1 rom and I have noticed a creeping problem. As time goes on, I can only seem to run 1 substantial program at a time.
For instance, if I try to run any of these programs in tandem:
HTC audio manager or Windows Media Player
Mundu mobile messenger
Opera
Internet explorer
Dictionary software
Outlook mail (sms/email)
Skype
the program in the background always closes. This is especially annoying when for instance I am listening to music and I get an email or sms, I go to check it and my music player just closes. Same if I try to browse the web and listen to music or check an sms, It is very annoying.
What causes this function in windows mobile and how do I turn it off?
As for memory, when I start I have 13-14 megs free memory. Any of these programs take an absolute MAXIMUM of 4-5 megs at peak usage. I should be able to run at least 2 together without a problem, and if another one does nto have enough memory, it shoudl just say so and not start, but not close out other programs...
I also have about 4-5 megs of free storage space on the phone.
any ideas on this one?
It seems as time goes on, I can't seem to run any more than 1 program simultaneously...
Reduce the amount of file space your browser have allotted for cache files and history.
My browser cache for both Opera and PIE are both pointed at the storage card which has about 500megs free. This problem occurs even if I am running any programs though, not just browsers...
It's either the memory shortage (which some of those programs can actually take much more than 4 or 5 mb to run.) Or you have it set to close on tap, within the task manager/x-button, instead of close on hold.
I use batterystatus, and it is set to tap and hold X to close, but I never use the X, I simply go to the start menu and open another program, then when I try to switch back to the other program, it is closed already.
How do I check if it is a memory problem?
For instance, if I run HTC audio manager, then get a message, I click reply, then after about 3 seconds into my reply HTC audio manager closes.
is there any way I can "force" the programs to stay open? Even if I were to launch a new program and it does not have enough memory, it woudl just not open rather than closing an existing open program...
To me, it sounds like you are running out of RAM, and programs that were running in the background are automatically closed. I'm not affiliated with Windows Mobile and hence not an expert, but I believe this (closing previously open programs rather than the new one) is the expected behavior in WM. Imagine getting a phone call and the phone app not opening since there's not enough memory because the OS didn't automatically close background programs...
I don't know of a way of changing the memory management behavior, but maybe someone else here does? I'd argue that you wouldn't want to anyway.
I'd suggest that you DO use the X button to close programs, otherwise I guarantee you will run out of memory and things will close automatically anyway. The difference is you won't have any say in what gets closed at that point. I added programs that I don't want to close with the X button (like Live Messenger) to the exclusive programs list in the Task Manager.
Second, I'd suggest you take any steps you can to increase your original pool of memory.
Darren, I understand your point, but it seems as if I have plenty of memory, and I can only run 1 program at a time. I don't mind so much the behaviour, it is just at the point of being ridiculous when I can only run 1 program at a time.
So you think that starting with 13-14 megs of free memory is not enough? How would I go about increasing this original pool of memory?
Also, even it I use the X button to close programs, that does not solve my problem anyways, whichever program is not in the foreground seems to close by itself anyway...
phony, I understand your frustration. I have had low memory problems myself, and I know that programs running in the background will close when that happens. That's why when I read your post it sounded like a memory issue to me.
I ended up tweaking a few things to try to get more free memory, like not running certain processes or services automatically at startup. I'm not sure if it is relevant to the ROM you are running, but see http://forum.xda-developers.com/showthread.php?t=312312.
This is definitely a memory problem. When the free program memory is lower than about 1MB (don't remember the exact number), the WIndows Mobile will send a WM_HIBERNATE to all the running program to release all the possible resources. If the memory goes lower, it will broadcast another message called WM_CLOSE to close all the background apps to release more memory. The only reason for apps that close on themselve is either low on mem or there are some apps in the background (maybe a virus) sending WM_CLOSE every now and then. To be honest, to have less than 15 megs of ram to start with is NEVER enough. Try to change the pool size if you don't like any of the great roms here. Hope this help.
I have noticed behaviour pointing to a memory leak on the X10 - After turning the phone on, I get less and less free memory after running ATK - over 110 MB right after turning the phone on to ~70 MB after 24+ hours.
The phone is heavily modified/customized, so it may not be an SE sw bug (ADW, Smart Keyboard, handcent, k9, etc...)
What's the best process tool you can recommend to look into this?
Let the phone handle the memory. dont worry.
+1 on that. Android its linux based and us meant to work like that. Empty memory is wasted memory.
-------------------------------------
Sent from my X10i
Android may be Linux based, but if *after killing all idle processes* memory is systematically dwindling, that means/may mean that one or more of these processes is allocating memory which it is then NOT being released - either by the process (more probable) or the system itself (less probable).
In other words, for the same set of running processes/applications , the memory usage should *not* systematically go up over time.
Linux itself has no automatic GC. Android does (Dalvik VM), but it takes some care from developers for that to work properly - no "loose" pointers to unused but still-referenced data, etc....
acmbc said:
Android may be Linux based, but if *after killing all idle processes* memory is systematically dwindling, that means/may mean that one or more of these processes is allocating memory which it is then NOT being released - either by the process (more probable) or the system itself (less probable).
In other words, for the same set of running processes/applications , the memory usage should *not* systematically go up over time.
Click to expand...
Click to collapse
I disagree, as processes are used/exercised the kernel will allocate the memory they need, after switching on the phone the processes are idle and occupy a small amount of memory. As they are used the process size will grow in main memory as they store or cache common data used by the process. That is why applications such as facebook may be slower at start off as the data needs to be supplied, once this data is cached it will run much faster as the data is already in main memory.
Linux/Android works on the principle that it's a waste not to use as much memory as possible.
Not to get into a GC flame war here: The principle you mention is right, its just that after one KILLS these processes (facebook for example) ALL OF the memory allocated by facebook should be relinquished to the system (ergo, appear as free).
I.e. if I start up my phone, and just have processes A B and C running and have lets say 120 MB free, and after using the phone for a while kill everything and *restart* ONLY processes A B and C, then I should have 120 MB free. At least tendentially (may have a different set of resident libs at the 1st and 2nd points in time, some other minor stuff may be different, etc..). However, I find that doing this over and over results in less and less free memory being available as time passes.
I am not saying I am *right* but a good process inspection tool would help to ascertain what is going on.
acmbc said:
Not to get into a GC flame war here: The principle you mention is right, its just that after one KILLS these processes (facebook for example) ALL OF the memory allocated by facebook should be relinquished to the system (ergo, appear as free).
I.e. if I start up my phone, and just have processes A B and C running and have lets say 120 MB free, and after using the phone for a while kill everything and *restart* ONLY processes A B and C, then I should have 120 MB free. At least tendentially (may have a different set of resident libs at the 1st and 2nd points in time, some other minor stuff may be different, etc..). However, I find that doing this over and over results in less and less free memory being available as time passes.
I am not saying I am *right* but a good process inspection tool would help to ascertain what is going on.
Click to expand...
Click to collapse
Wrong.. it should NOT be returned to the system.. but it should be marked as "disposable" IF another process wants to use it. That is the way linux usually do.. That is why the "Free"-value is misleading. As the "Free"-value is not the sum of "Free" and "Cached" values. when you "unload" a lib it is not completely removed from memory, it is just marked as "cached" instead. Saving tremendous ( ) amount of battery and time when, if, the user wants to use it again before overwritten by another memory-hungry application..
Regards // OwL
does all this mean we don't really need advanced task killer?
or does the advanced task killer kill the cpu process? ( as a result longer battery life)
robbyf66 said:
does all this mean we don't really need advanced task killer?
or does the advanced task killer kill the cpu process? ( as a result longer battery life)
Click to expand...
Click to collapse
advanced task killer kills the application itself, so that nothing more is executed by that application thread(s). wether dependent libraries are kept loaded or not does not affect battery time when not used. Advanced task killer does not actually unload any libraries it only kills the process.
I personally hardly never use advanced task killer, as it is not needed as long as you make sure to run applications that does not keep the phone from going into sleepmode. Those programs are just simply bad coded.. I instead have a CPU-meter application in the task-bar and if I see that the CPU-time is extensivly used after the application has been put to background, then I might use a taskkiller to stop the bad application. But that scenario is rare... I usually get 50h+ of battery time per charge, whatever I do with it.
Regards // OwL
Good day!
I've tried a few different apps now, Memory Usage, Advanced Task Killer, and I seem to hover between 110m to 25m. I kill some apps and it jumps back up to 110 and then slowly works its way back down to the mid 20's. Is this normal?
Tips? What is your available memory like?
To sum it up: Free memory is useless memory. You should have as little memory free as possible.
Explanation. Android handles memory management really well. When an app is opened and needs more memory it will shut down unused processes and free up memory on an as needed basis. For apps this can be everything from pausing individual functions all the way to saving an apps state to disk and restoring it the next time it's opened.
Task killers are mostly solutions looking for a problem, I've been running without one for months and my amount of free memory fluctuates as expected when surfing the web and things like that but so far there haven't been any times where I've had to free up memory. So don't stare yourself blind on memory meters and try freeing up memory. Android handles that well enough on its own.
+1..
The message you have entered is too short. Please lengthen your message to at least 10 characters.
That's good info! I kinda knew I was making something out of nothing with the numbers. The phone has been fine in terms of performance.
my 2 cents....i typically have between 30-60mb free. phone does not lag or anything. i used task-killer for a few days when i got phone, then actually thought about what it was doing and the way the system (linux based) is designed. i ditched it and have not looked back!
ps. my phone is rooted R2BA024 firmware, fwiw.
I usually have like 80 mb free ram just for the case and i use task manager to kill apps that are using data connection when i dont need them
I got totally obsessed with task killing but having read a lot of the lads reports on here I am on my third day of not touching it and I have to say my phone is doing fine all by itself!
goth50 said:
I usually have like 80 mb free ram just for the case and i use task manager to kill apps that are using data connection when i dont need them
Click to expand...
Click to collapse
I think you'd be better off setting up data synchronisation properly. I'm assuming you're talking about background syncing of course. So that you don't accidentally kill an app in the middle of a sync which might cause corruptions. I've had that happen when synching my gmail to a linux machine and the network went down, the cleanup required was insane and I lost a whole months worth of mails from the google servers.
ddewbofh said:
To sum it up: Free memory is useless memory. You should have as little memory free as possible.
Explanation. Android handles memory management really well. When an app is opened and needs more memory it will shut down unused processes and free up memory on an as needed basis. For apps this can be everything from pausing individual functions all the way to saving an apps state to disk and restoring it the next time it's opened.
Task killers are mostly solutions looking for a problem, I've been running without one for months and my amount of free memory fluctuates as expected when surfing the web and things like that but so far there haven't been any times where I've had to free up memory. So don't stare yourself blind on memory meters and try freeing up memory. Android handles that well enough on its own.
Click to expand...
Click to collapse
Heh...handles memory very well, but how about the battery life!? The more apps you have- the less power you've left.
mymagicmyhero said:
Heh...handles memory very well, but how about the battery life!? The more apps you have- the less power you've left.
Click to expand...
Click to collapse
That's debatable, most background apps drain miniscule amounts of power. The exception naturally being things that makes use of the hardware while backgrounded by playing music, syncing, calculating pi or things like that. Most apps though, just hang out in memory not really doing anything. A lot of the time, if not most, it's more efficient staying there as opposed to shutting it down and starting it up again later.
+1 yes, just hanging out idle in memory wont cost you any battery, the memory will be on an base current either way, what does cost you battery is the read and write actions to memory so if you frantically clean out that memory your phone will have to write alot more to it working with your different apps resulting in a slower (less prepared) device sucking more battery then neccessary. Leave the memory handling to your device ;-)
Sent from my X10i using XDA App
I am a beginner developer and I am sure I have a memory leak in my android application. When I open my app for the first time and check the heap size using DDMS tool from Eclipse it shows 4.5 MB. With every new opening of my app (close and reopen it) the heap size is increasing until it reaches 5.8 MB and then it settles at this size going up or down just a little bit. I also see that the amount of allocated objects increases from 44k to 60k. That is crazy I guess. But why it stops increasing at that particular point of memory (5.8 MB) and amount of objects (60k)? Furthermore, for some reason Android Application Manager's "Cached background processes" section shows that my app memory consuption increases from 10 MB to 24 MB and settles there. Why do these numbers differs from what DDMS shows? Anyway, these two tools show the same behaviour: that is with every opening my app's memory is increasing. I have tried setting all my instance variables to null in onDestroy() methods of my every activity or fragment but it didn't help. What else can I do?
Sent from my GT-I9300 using XDA Free mobile app
Maceee said:
I am a beginner developer and I am sure I have a memory leak in my android application. When I open my app for the first time and check the heap size using DDMS tool from Eclipse it shows 4.5 MB. With every new opening of my app (close and reopen it) the heap size is increasing until it reaches 5.8 MB and then it settles at this size going up or down just a little bit. I also see that the amount of allocated objects increases from 44k to 60k. That is crazy I guess. But why it stops increasing at that particular point of memory (5.8 MB) and amount of objects (60k)? Furthermore, for some reason Android Application Manager's "Cached background processes" section shows that my app memory consuption increases from 10 MB to 24 MB and settles there. Why do these numbers differs from what DDMS shows? Anyway, these two tools show the same behaviour: that is with every opening my app's memory is increasing. I have tried setting all my instance variables to null in onDestroy() methods of my every activity or fragment but it didn't help. What else can I do?
Click to expand...
Click to collapse
Are you really sure you have such a leak? Usually it happens on rotation or so and it keeps on increasing, using far more memory than your 5.8 megs. If you quit your app with the home button (instead of back) Android still keeps a lot of its data in memory so it is faster to be reopened. It still depends on what your app is doing, so releasing any unneeded receivers or caches is still a good thing to do, but in your case an increase of just 1.3MB is not significant enough to really worry about it. I don't know what the Android Application Manager is showing since I haven't used it yet.
SimplicityApks said:
Are you really sure you have such a leak? Usually it happens on rotation or so and it keeps on increasing, using far more memory than your 5.8 megs. If you quit your app with the home button (instead of back) Android still keeps a lot of its data in memory so it is faster to be reopened. It still depends on what your app is doing, so releasing any unneeded receivers or caches is still a good thing to do, but in your case an increase of just 1.3MB is not significant enough to really worry about it. I don't know what the Android Application Manager is showing since I haven't used it yet.
Click to expand...
Click to collapse
Well, I wouldn't worry if that 5.8 MB had gone down after I quit my app pressing back button, but it hadn't, so it keeps me thinking I have a memory leak. And yes, it keeps on increasing on rotation too, because the activity is recreated. It doesn't increase only when I close and open my app using home button because activity isn't recreated then. By the way, I use FragmentPagerAdapter for ViewPager and CursorAdapter for ListView. Maybe one of these could be the cause. Thank you.
Sent from my GT-I9300 using XDA Free mobile app