02-13-09 11:00 AM
27 12
tools
  1. bmn's Avatar
    Why do so many posts about the different OS upgrades contain information about what people's memory usage?

    Blackberries are Java devices and Java clears memory "whenever it feels like it". So any details on what your memory usage was before/after an upgrade to a particular OS version are basically useless.
    Even "fresh boot" numbers are suspect as you have no idea if garbage collection was run during boot.

    My Java knowledge comes from J2SE which will frequently fill however much memory is allocated to the JVM before doing GC.
    If there are any J2ME/Blackberry geeks in the forum please correct me if I'm wrong.

    Otherwise I would like to humbly request that everyone stop caring about memory usage.
    02-12-09 12:10 AM
  2. anon(12291)'s Avatar
    Why do so many posts about the different OS upgrades contain information about what people's memory usage?

    Blackberries are Java devices and Java clears memory "whenever it feels like it". So any details on what your memory usage was before/after an upgrade to a particular OS version are basically useless.
    Even "fresh boot" numbers are suspect as you have no idea if garbage collection was run during boot.

    My Java knowledge comes from J2SE which will frequently fill however much memory is allocated to the JVM before doing GC.
    If there are any J2ME/Blackberry geeks in the forum please correct me if I'm wrong.

    Otherwise I would like to humbly request that everyone stop caring about memory usage.
    Amen. Its kinda the same as how people obsess over how much ram is currently being used - as long as everything is cleared/swapped with no impact on my usage, I can have 3 kb free and not care.

    That being said, I think its mainly psychological, as it gives a quantitative measure of perceived performance.
    02-12-09 01:38 AM
  3. SnowBrdPaint's Avatar
    totally agree and this argument is passed over when mentioned in threads like this...

    yes there were memory leaks in old betas... but just because your free memory is less, doesn't mean anything.

    For example, Linux/Unix and most likely the storm, prefetches data it thinks your going to use. This is good since it makes your phone faster. If the memory becomes low, it should remove the prefetch first. (I hope this is what the storm is doing)

    Anyway you guys (and gals) will become more accustomed to this with windows 7 since it will prefetch everything. Perhaps Microsoft will not include that "used" ram when you run system stats. If rimm did this, no one would complain (well at least less).
    02-12-09 04:46 AM
  4. TheMisses's Avatar
    People are just dumb... Why have ram if you don't use it? That is why its there, to be used so things can be sped up.

    I think MS should use a mem counter instead of a clock on the desktop and have windows try to use as little memory as possible, so only 64MB is used out of the 3,27GB available to the OS... Lets see how people respond when their harddisk has to do that work then.... Same goes for this thing.

    People stop whining.... OR try to disable your virtual memory (page file) on your windows box and report back after a day orso. If you can.....
    (SSD users not included )
    02-12-09 07:00 AM
  5. bigman2's Avatar
    Tossing around technical terms like "memory leak" makes you sound like you have a friggen clue what it actually means, and are thus smart. Your opinion on the subject should be valued more highly, because you can brandy about terms like "memory leak". Never mind the fact that what you describe lacks the most important second half of a memory leak, in that the memory is NOT automatically freed when it's needed by something else.

    I've been a pretty constant source of cold water on a lot of these threads, though for the most part I'm simply ignored by the majority, as they continue on.

    And as TheMisses says, and the saying we have in IT land... Free RAM is wasted RAM. It's not doing you any good if it's just sitting there perpetually idle. May as well use it for SOMETHING.

    Of course some of the confusion seems to stem from RIM's rather poor use of the word memory in multiple contexts about the Storm. Storage devices, like the onboard 1GB and the 8GB card VZW customers received, is all collectively referred to as memory. Someone who's been in IT for a good while will have already memorized the difference and won't even think about it, but it's easy to forget the average person will be confused by this. So it would be nice if RIM could go in and change a few text labels to better reflect what is memory and what is storage. That would go a long ways to helping put an end to this.
    02-12-09 08:37 AM
  6. howie's Avatar
    The reason people always talk about the memory on the BlackBerry is because it's not like RAM on a computer that makes it go faster, but actually slows down the more is used. BlackBerries do not have a swap file like Windows does. Also, different OS installs have different install sizes on the device -- and people can customize it a bit (remove certain things they do not use). The biggest problem is that when memory gets to a certain point it SHOULD free up, but many times does not and it forces the BlackBerry to make sacrifices, by deleting things such as call logs, address books, SMS/MMS/emails. Not to mention that many programs are coded poorly and have major memory leaks in them.
    02-12-09 08:47 AM
  7. aaronwh98's Avatar
    Umm....I have my page file disabled on all my computers with no performance hit. In fact, it seems to speed things up in XP (most) and Vista (only a little). Windows 7, though, actually seems to be handling paging correctly.

    Anyway, that was off the subject. But yeah, I agree, as long as your BB is functioning properly you probably shouldn't care how much memory it's taking up. That being said, I've found myself almost as obsessed over memory as some others because in general, there just seems to be so little available to applications. I worry about what'll happen when the app store comes out and I start installing a bunch of 3rd party apps.
    02-12-09 09:11 AM
  8. bigman2's Avatar
    The reason people always talk about the memory on the BlackBerry is because it's not like RAM on a computer that makes it go faster, but actually slows down the more is used. BlackBerries do not have a swap file like Windows does. Also, different OS installs have different install sizes on the device -- and people can customize it a bit (remove certain things they do not use). The biggest problem is that when memory gets to a certain point it SHOULD free up, but many times does not and it forces the BlackBerry to make sacrifices, by deleting things such as call logs, address books, SMS/MMS/emails. Not to mention that many programs are coded poorly and have major memory leaks in them.
    See, what you describe WOULD be a memory leak, but most people scream memory leak if their free app mem drops by 0.1MB, and then go do a battery pull like every 5 minutes.

    One of the benefits to running on a JVM, is that memory leaks should be pretty much impossible for any program that is not perpetually running. Something like TalkLock or VyMail might be susceptible to memory leaks, but if you close Google Maps, the resources it was using can then be freed up.
    02-12-09 09:23 AM
  9. camoto's Avatar
    See, what you describe WOULD be a memory leak
    AMEN.

    It totally drives me nuts. Everyone is all like "OMG HUGE MEMORY LEAK". There's no way for the average BB User to prove it's consumption versus a leak.
    02-12-09 10:26 AM
  10. mrcoyote's Avatar
    The biggest problem is that when memory gets to a certain point it SHOULD free up, but many times does not and it forces the BlackBerry to make sacrifices, by deleting things such as call logs, address books, SMS/MMS/emails.

    The above is my BIG thing about Blackberry - my first BB was a Pearl... I did battery pulls as many times as 10x a day because of "memory" issues - I KNEW that if it hit "0" my SMS/Emails/Call Logs would get wiped out.

    Anyone know if the Storm will do this do or does it manage things better? I do reboot my storm once a day (needed or not) to be safe... but I still have a paranoia to check on available memory a few times a day.
    02-12-09 10:27 AM
  11. howie's Avatar
    AMEN.

    It totally drives me nuts. Everyone is all like "OMG HUGE MEMORY LEAK". There's no way for the average BB User to prove it's consumption versus a leak.
    Actually you can. If you do not use the BlackBerry over a 12 hour period and just leave certain apps running you will see it eats away at the free memory -- those are the ones I am referring to as poorly coded. Myspace was one that did this for me - it used almost 20mb in a 12 hour period with me not using the device for any reason, no phone, email etc. During any given day my BlackBerry stays around the same "free memory", no matter how long ago I rebooted.. so makes it easy to see. Currently 46,909,814 and doesn't generally go below 42mb unless I run specific apps like myspace, then it drops down to around 12-15mb over just one day.

    While I agree most people cry wolf for everything, there are some times that it is accurate.
    02-12-09 10:37 AM
  12. ThePerfectStorm's Avatar
    I started to find this kind of humerous myself......

    This is my 1st BB and I had been on here researching everything about it and would come across these threads all the time so I thought it was actually something that mattered......

    The 2nd day I had my storm I checked my memory just for the heck of it and was running 0.0mb, BUT still not lagging....

    Since then I don't worry about it.........
    02-12-09 10:53 AM
  13. camoto's Avatar
    Actually you can. If you do not use the BlackBerry over a 12 hour period and just leave certain apps running you will see it eats away at the free memory -- those are the ones I am referring to as poorly coded. Myspace was one that did this for me - it used almost 20mb in a 12 hour period with me not using the device for any reason, no phone, email etc. During any given day my BlackBerry stays around the same "free memory", no matter how long ago I rebooted.. so makes it easy to see. Currently 46,909,814 and doesn't generally go below 42mb unless I run specific apps like myspace, then it drops down to around 12-15mb over just one day.

    While I agree most people cry wolf for everything, there are some times that it is accurate.
    I should have put more emphasis on "average user".

    But yes, I agree with your scenario. There seems to be a specific group of users who become completely consumed and obsessed by the free memory numbers.
    02-12-09 01:13 PM
  14. bmn's Avatar
    Actually you can. If you do not use the BlackBerry over a 12 hour period and just leave certain apps running you will see it eats away at the free memory -- those are the ones I am referring to as poorly coded. Myspace was one that did this for me - it used almost 20mb in a 12 hour period with me not using the device for any reason, no phone, email etc. During any given day my BlackBerry stays around the same "free memory", no matter how long ago I rebooted.. so makes it easy to see. Currently 46,909,814 and doesn't generally go below 42mb unless I run specific apps like myspace, then it drops down to around 12-15mb over just one day.
    No, this is exactly what we're discussing here. The fact that running myspace causes your memory usage to steadily increase means nothing. The blackberry just hasn't decided to do GC yet.

    As an example, take this snippet of java code:
    Code:
    for (int i = 0; i < 1000;++i)
    {
    String foo = new String("bar" + Integer.toString(i));
    }
    This will create the string "bar1"..."bar2"...etc...1000 times, and release the reference every time.
    In a "perfect world" the memory would stay the same because it is being released after every call. But in Java world, the JVM decides when to free memory.
    So in the situation above, you may see enough memory to hold 1000 "bar"s in memory, when in fact the application is only using 1 at any given time.
    There's nothing wrong with the code, it's not poor coding, it's just up to the JVM to actually purge memory when it wants to.

    Now, if you're seeing situations where the Blackberry cannot allocate new memory and applications crash because of it, then THAT would be a problem.
    But memory usage should not be used as a metric for application performance or quality.

    Any BB software devs want to chime in on whether you can create a cute little app that does "System.gc()"? Could probably sell it for millions to all the people paranoid about memory usage and bragging rights "Hey I've got 50 megs free WOOO!"
    In fact, it may be a useful tool for developers to confirm that they aren't leaking memory.
    Link here:
    BlackBerry JDE 4.7.0 API Reference: Class System
    public static void gc()

    Runs the garbage collector.

    Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.

    The call System.gc() is effectively equivalent to the call:

    Runtime.getRuntime().gc()


    See Also:
    Runtime.gc()
    Looks like it's part of the API.
    02-12-09 06:17 PM
  15. Valace2's Avatar
    I rarely ever post in these types of threads, mainly because I don't know what you all are talking about half the frigin time. I prefer to be the annoying guy in the waiting room threads. That an because I have never had a problem with available memory. I have a ton of apps on my Storm, and my memory has always stayed pretty constant in the upper 40's after a fresh install.

    I get the concept of what a memory leak is. I know that Ram is meant to be used and that you never really start to suffer until it starts getting really low.

    Since I have installed .103 I have begun to experiance an unexpected drop in available memory. Did a battery pull thanks to a bbm freeze about an hour ago, and have since made two phone calls. My memory has dropped 10 megs in that time. I also noticed that it dropped into the mid 20's earlier in the day, without me having used it hardly at all. and it has never went that low.

    So I would assume that I am experiancing a memory leak. Yes or No?

    I also realize that you have ta close everything. I don't know how they work, but I know how to use them. Had a Pearl before, and learned early on to always make sure was shut off.
    02-12-09 06:43 PM
  16. bigman2's Avatar
    No, there are two things that need to happen in order for it to be a memory leak:

    1: Memory is allocated/reserved/used
    2: Memory is not freed properly when it is no longer being used by a running program

    It's that second part that seems to trip so many people up. If I were to speculate a moment on why, I would say it's probably because we traditionally think of leaks as sort of a gradual loss of some substance (such as water) from a container. With computers, there's a second condition that needs to be met.

    The other kicker is that without some kind of tool to really break down what processes have what memory allocated, you can't really tell whether or not it's just the phone doing some caching to improve performance, or if there really is an app sucking down memory in a leak. So even if you had an app that manually invoked the garbage collector, you might well have more free app memory, but you also might have a slower phone overall.
    02-12-09 06:59 PM
  17. Nofanboy's Avatar
    My experience is that until the .8X OS's, memory drops would equal lower performance. If I had less than 20 MB and decided to use the phone more heavily, sooner or later it would freeze and require a battery pull. With .99 I let it go down and didn't notice any performance hit until it reached 10 MB. It would still work, but I would see more of the little clock for many operations. Curiously, the drop is always more pronounced when the phone is idle. When I use e-mail or browse the internet, memory goes up.
    02-12-09 09:02 PM
  18. bmn's Avatar
    No, there are two things that need to happen in order for it to be a memory leak:

    1: Memory is allocated/reserved/used
    2: Memory is not freed properly when it is no longer being used by a running program
    Plus (for Java):
    3: Gabage collection has run and freed the unused memory.

    That seems to trip people up about Java memory management versus memory management of typical applications.

    ...you can't really tell whether or not it's just the phone doing some caching to improve performance
    Well, caching is a completely separate debate. Which falls under "where does my memory go?".

    Some vague/general categories (other developers reading this, please forgive me):
    1: Allocated and in-use for code
    2: Allocated and in-use for data, this includes an optional cache to speed up data access
    3: Unallocated memory (memory not being using any more) that hasn't been freed by garbage collection

    Number 3 is unique to Java and can consume all available memory without hurting performance much. This is the memory I'm speaking of because it destroys any meaning of "free memory". The memory is "free", it's not being used any more, it's just sitting there waiting for the JVM to truly reclaim it.

    And the categories above only cover the Java environment. Unless BB has a processor for natively running Java, there is an additional layer of native code on top. That is where true old-fashioned memory leaks can occur.

    @Valace2: Sorry, I'm trying to keep this as easy to follow as possible. But there's a lot of magic to how Java manages memory. Just google "java memory management" to get an idea of how misunderstood it really is.
    Basically, using "free memory" (according to the menus available on the Blackberry) will not tell you if the memory is really "in use" or not. And cannot tell you decisively if an application (or applications) is leaking.

    @Nofanboy: It is quite possible that certain releases of the Blackberry OS have a horribly broken JVM and are unable to properly perform garbage collection, but "free memory" would never tell you that.


    It really sounds like there may be demand for a little app which does System.gc();.
    I'll fire up the Blackberry JDE this weekend and see what I can do (my first BB app, I'm so excited )
    It should be something really simple, just a box which says "free memory" containing the same value as is available through the Options>Memory menues and a button saying "Run Garbage Collection".
    Clicking the button would run GC and update the "free memory" value. If that value didn't change after garbage collection then it could suggest a leak.
    02-12-09 10:21 PM
  19. anon(12291)'s Avatar
    The other kicker is that without some kind of tool to really break down what processes have what memory allocated, you can't really tell whether or not it's just the phone doing some caching to improve performance, or if there really is an app sucking down memory in a leak. So even if you had an app that manually invoked the garbage collector, you might well have more free app memory, but you also might have a slower phone overall.
    I'd like to emphasize the point in the bold to others reading this thread. Remember. you're using a phone - an advanced one at that. It needs to collect network data, log application usage and cache other things.
    02-12-09 10:36 PM
  20. tclancy911's Avatar
    BMN-

    It really sounds like there may be demand for a little app which does System.gc();.
    I'll fire up the Blackberry JDE this weekend and see what I can do (my first BB app, I'm so excited )

    Thanks for offering.
    Just a thought.
    in your little program, it might be neat to:
    1. grab the value before running cleanup,
    2.run cleanup, and then
    3. display both values
    02-12-09 10:55 PM
  21. anon(12291)'s Avatar
    It sounds like a good idea if it works, but I don't know how good of a model RIM would have if a single program can call garbage collection for other userspace/system level apps... of course, that's just my blind speculation. I'd love to be proven wrong
    02-13-09 12:07 AM
  22. bigman2's Avatar
    It sounds like a good idea if it works, but I don't know how good of a model RIM would have if a single program can call garbage collection for other userspace/system level apps... of course, that's just my blind speculation. I'd love to be proven wrong
    It wouldn't be. It would be triggering the JVM garbage collector which would then inspect all memory in use to see if any of it can be freed up.
    02-13-09 12:25 AM
  23. bmn's Avatar
    Ok, some interesting results.
    I made a quick and dirty app which does the following on my Storm:
    Code:
    Total Memory:
    77982996
    FreeMemBefore:
    59530392
    FreeMemAfterGC:
    59893001
    (take those values with a grain of salt, as I've run the GC a few times during my testing, the initial differences between "Before" and "After" where much bigger originally)

    None of those values match what is in "Options->Memory->Application Memory" (which is currently at 16.7MB).
    Even weirder, sometimes "Total Memory" changes, but that actually agrees with what is in the documentation:
    public long totalMemory()

    Returns the total amount of memory in the Java Virtual Machine. The value returned by this method may vary over time, depending on the host environment.

    Note that the amount of memory required to hold an object of any given type may be implementation-dependent.

    Returns:
    the total amount of memory currently available for current and future objects, measured in bytes.
    Also interesting, according to VZ: BlackBerry® Storm™ 9530
    The Storm has 196MB RAM, so there must be a different space allocated for applications to run in. Otherwise I'd expect "Total Memory" to be the full 196MB.
    Which makes sense, you'd still want the phone to work, battery to charge etc even if all your applications go crazy.

    I'll see about bundling the app up and hosting it somewhere if anyone wants to toy around with it.
    (I should also probably break down and register a real CB.com account instead of using this bugmenot.com account)
    Last edited by bmn; 02-13-09 at 01:35 AM.
    02-13-09 01:33 AM
  24. bubbatech's Avatar
    I pay absolutelly no attention to posts about memory utilization for the reasons mentioned by the OP. Many of the people who post here are well meaning but don't understand much about how these devices work and are not familiar with how to troubleshoot a problem on complex devices such as this one. So the OP's admonition should be extended to most posts about reliability, freezes, reboots etc unless more information is given about how the device is configured. I very much doubt that RIM takes any of these posts very seriously - they are simply not useful.

    I should also point out that one should not call these people "stupid" as someone did earlier in this thread. Cut those guys some slack - they are users, not engineers
    02-13-09 09:43 AM
  25. briananderson's Avatar
    As long as your device keeps working, you can make and receive calls, and your applications are doing what they are supposed to when you need them to, what difference does it make how much memory you have free at any given time?

    Memory allocation is a fluid and dynamic process. Free memory ebbs and flows like the tides. Hitting the panic switch and reverting back to a previous build simply because you are a few MB's lower than a non-existent benchmark tells you you should be is preposterous.
    Last edited by briananderson; 02-13-09 at 10:35 AM. Reason: Typo
    02-13-09 10:34 AM
27 12
LINK TO POST COPIED TO CLIPBOARD