I am looking to ensure my app does not consume too much memory on what are still fairly resource constrained devices. Several days ago I was using Instruments to determine how much memory my app was using and I was getting around 4-8 megabytes for Live Bytes. Today I run Instruments again and I am up around 30-35 megabytes for Live Bytes. I don't believe I have made any significant changes to my code between these two times.
My app uses an MKMapView with a custom tile overlay. I put off updating XCode for a fairly long time, and so I suspect that the difference may be that my iOS simulator was still using Google as opposed to Apple maps a few days ago, until I upgraded XCode.
As a small test, I created a new test app that just has an MKMapView, nothing else, and ran Instruments on it. It is common for the Live Bytes of this app to be on the order of 50-90 megabytes, even though it has no custom code whatsoever - I just drag n' dropped the MKMapView on.
Whether this is intentional on Apple's behalf for the new maps to use this much memory I do not know. Perhaps the map tiles are shared across apps and this is fine. Either way though, it complicates coming up with a reasonable approximation for how many Live Bytes I can safely use, given that most earlier suggestions are on the order of 5-20MB, and Apple's MKMapView consumes 50-90MB on its own.
Is there another useful metric I can go by failing Live Bytes being any use now?
Edit: looks like for others this is a legitimate memory management problem and causing app crashes: iOS6 MKMapView using a ton of memory, to the point of crashing the app, anyone else notice this?
Related
I'm using a flutter for a new project and everything's been great until today.
The app we're building allows our employees to download and view some internal file types on their devices. One feature request we have gotten is to show how much storage space the device has left. Some of our employees download a lot of files and keep running out of space. I tried searching for a way to do this but I can't find anything. It's the first time so far I've been completely blocked using Flutter.
Does anyone know of a way to get the fee storage space a device has for both iPhone and Android?
This is a perfect use case for platform channels which could be part of your main project, or implemented in a plugin.
On Android, use StatFs; on iOS use volumeAvailableCapacityForOpportunisticUsageKey.
I've been working on an app I'm building, and until now it's had a reasonably small footprint. Today, however, I was looking into why my computer was suddenly running slowly, and I can see the app in Chrome is occupying around 1.2 GB of RAM!
Looking through my commits, I can't really spot anything suspicious. Where should I look when trying to debug enormous memory usage? I'd post code examples, but I can't see anything relevant, really.
To check what React is doing, try go get a snapshot of your app using the React profiler: Introducing the React Profiler
For everything else, try checking out the built-in profiler in the Chrome developer tools: Chrome DevTools: JavaScript CPU Profiling in Chrome 58
Those should be two good starting points to look at.
Sorry, we might need some more clarification about what you've tried.
It could be a ton of things. Most likely you're storing some sort data from the server or have some sort of memory leak (like adding something to a collection, but never deleting it).
One thing you can do is use the Chrome profiler to see when your memory climbs:
(This can be found in the drawer that open when you push Esc.)
The "Performance" tab can also be nice if you want to view the memory on pageload (using the 🔄button). Just make sure that memory is checked.
I'm developing a Magazine app and trying to find the best strategy to optimize performance and stability. The app should be able to handle +100 pages and expect users to swipe between them fast and smoothly.
With all this in mind, this is what I've tried so far.
The basic structure would be using tabs, with tabs bar hidden, to allow user swipe. Since loading + 100 tabs with huge images would be a mistake, I always mantain three tabs: the current page, the previous and the following. With a selection listener I change the positions accordingly.
The way I load and dispose images as selection changes is the big deal here. The app downloads the images from Internet and cache them in FileSystemStorage. Those images are 768 x 1024. This is what I've tried with different luck:
Simply retrieve the images from FileSystem everytime a new page is requested:
if (FileSystemStorage.getInstance().exists(rutaImagen)) {
try {
int size = (int) FileSystemStorage.getInstance().getLength(rutaImagen);
EncodedImage imagenPubli = EncodedImage.create(FileSystemStorage.getInstance().openInputStream(rutaImagen), size);
} catch(IOException io) {
}
}
This has proven to be inefficient and risky in terms of memory usage. My iPad mini launch frequent low memory warnings, and end up killed by jetsam after a little while.
Store the images in a WeakHashMap, so Images don't need to be constantly loaded form FileSystemStorage, which seems to be the cause of problems and too expensive. Only if they are garbage collected, the first method comes in action.
This solution perfoms better, and the memory warnings are dramatically reduced, but are still there. After stressing hard the app, 15 or 20 minutes later jetsam jumps in and kill the app.
Similar approach: instead of WeakHashMap, I have tried CacheMap. This has been the best solution for me so far. I have to push hard to see some memory warnings once in a while, and no crash so far. Still not enterily happy though, because I believe I should not see any memory warnings at all.
I talk about iOS only here because the app performs well on Android whatever method I use, and I have never got any Out of Memory there.
What do you think? Am I in the right path? Would you guys use a different approach?
Thanks
I believe that you should use the "let-it-be-done" approach. So far you have tried to code everything yourself, while codenameOne has many optimized way of doing it. The easiest way would be to use a MultiList, which will display your images (by using an UrlImage). The UrlImage will allow codenameone to handle the caching and else. Basically, the image will be loaded when viewed and placed in cache afterwards.
It's unclear from the question where the magazine page is just an image. If so I would suggest using the ImageViewer class as it was designed exactly with the use case of an infinite list of large images to swipe and zoom thru.
The general strategy with the Tabs seems like a good start if you need something more elaborate than images. If it doesn't perform well you can always substitute Tabs for something else.
I'm using a late-2011 MacBook Pro with recently upgraded 16GB ram. Recently I'm experiencing high system resource usage when I'm doing the Angularjs.org Free Course provided by CodeSchool - "Shaping Up with Angular.js".
Angular.js is a framework for responsive web app, and, I believe the CodeSchool campus itself is also a responsive web app. I would expect it takes up a little bit more resources but what I'm experiencing is just too much:
Laggy - the screen freeze while I type, after I finish typing the whole line of code (a few seconds), the words come out.
Spinning Beach Ball - if I keep it too busy, such as while I'm going to scroll around and check my codes for possible mistake, the Spinning Beach Ball may appear.
But everything is just became such abnormal while I'm focus on that website. From the Activity Monitor, I observed that:
Memory - http://campus.codeschool.com is taking up 1GB ~ 3GB memory consistently.
CPU - something may be wrong with WindowServer process, as I've actually never seen it appearing on the top of my list before this.
Anyone has some clues on what's going wrong? Possible cause?
Stumped here. Posted a similar question before. We have a pretty large WPF app that on some machines runs great, but on others, all of a sudden, one of the CPU cores gets pinned at 100% (just one core) and the app freezes. It usually seems to happen when showing a context menu or a combobox drop-down (i.e. Popup controls) which is why we can't debug this since no user code is executing at that time. It's driving us crazy because again, on most machines it runs fine, but on a few, it freezes.
The odd thing is when we run it in a VM, it runs great there too! Crazy! Not sure what's causing this, or more importantly, where to even begin to look because as I said, no user code is running.
This happens on only about 10% of our machines, but it consistently happens on those machines. All are clean (i.e. relatively fresh OS installs, no crazy apps, etc.) and mostly identical machines spec-wise: similar CPUs, similar RAM, same video drivers and service packs.
So as I stated in the title, can anyone suggest possible reasons why a WPF app would pin the CPU and lock the app on some computers but not others? We're just stumped!
Found it!! Turns out there's a bug in .NET 4.0 regarding UI Automation and the changes MS introduced. Here's the info, and the fix! (Note: Even if you call MS, they will send you a link, but it's always a broken link. I managed to track this down manually.)
Note: Their article talks about a specific case that causes this behavior, but if you google around, you'll see tons of issues around hangs related to those DLLs. The latest is they're promising a fix in the .NET 4.5 runtime (from a MS post on this issue.)
Here's the KB article...
http://support.microsoft.com/kb/2484841/en-us
...and here is the actual hotfix.
http://archive.msdn.microsoft.com/KB2484841/Release/ProjectReleases.aspx?ReleaseId=5583
Crappy video driver? Pull two machines - one where it happens, one where not, and start analyzing differences. Could be hardware defects, bad video drivers, anything in that area. WPF uses the GPU to render if one is there.
Since you seem quite to lack options, i would advice to make a new project with just most basic ComboBox in the Window, doing almost nothing. This should work (check :-) ). Then you add features one by one in the ComboBox and test, for instance when you add command, start with empty one. Do this until it 'breaks'. So you know which feature is the culprit.
You didn t say if all was working with software rendering.