AIR mobile runtime memory leak? - actionscript-3

I have an app developed with AIR 3.7 for iOS (iPad)
The app gets very sluggish after a while, eventually crashes.
I've been -very- careful to pool objects where possible and cleanup / nullify all objects once they're not needed any more.
Profiling the app in Scout returns a pretty stable memory profile (the peaks and the lows translate very well to what's happening on screen)
Simultenously profiling the app using XCode's Instruments, shows me that the apps memory consumption constantly rises up to the point the systems spends more time throwing memory warnings than anything else.
Here are screenshots of both profilers: they show AS3 memory usage being pretty stable. On the app level though, memory consumption keeps rising...
https://dl.dropboxusercontent.com/u/608333/AIR_memory_leak.zip
If AS3 is not leaking any memory (according to scout), but the app is (according to Instruments), would I be right assuming there's a memory leak in the AIR-runtime itself?
thanks for your feedback!
bart.

Related

Chrome garbage collector going crazy

Using Version 48.0.2564.109 m.
We have a javascript web app (built with ExtJS). In Chrome, when we leave our app sitting there for a while, the GC starts going nuts. In Task Manager, you can see the CPU constantly spinning around 25%.
I took timeline snapshots and CPU profiles, and you can see the GC, about 10 times a seconds, try to collect memory, but collects 0B.
Our app is a large enterprise application and does use quite a bit of memory and updates the screen periodically.
But, there is absolutely no javascript code running during this time. So I can't see that it is something our app is actively doing
Does anyone know what could be triggering this?
It is killing performance of our app.
Also, it only happens when our tab is active. If you switch to a different tab, the CPU dies down and the GC stops.
Is there other data I need to collect to help determine this?
What is your app current JS heap size? You can check it by collecting timeline and enabling memory check box.
It looks like your app is close to the V8 memory limit, so V8 is trying to free some memory. If it is expected for the app to use that much memory, you can increase the limit on your host with something like: --js-flags="--max-old-space-size=2048"
Otherwise it might be just a memory leak in your code. Use heap profiler to hunt it down.

Direct3D texture resource life cycle

I have been working on a project with Direct3D on Windows Phone. It is just a simple game with 2d graphics, and I make use of DirectXTK for helping me out with sprites.
Recently , I have come across to an out of memory error while I was debugging on 512mb emulator. This error was not common and was the result of a sequence of open, suspend , open , suspend ...
Tracking it down, I found out that the textures are loaded on every activation of the app, and finally filling up the allowed memory. To solve it , I will probably go and edit it so as to load textures only on opening but activation from suspends; but after this problem I am curious about the correct life cycle management of texture resources. While searching I have came across to Automatic (or "managed" by microsoft) Texture Management http://msdn.microsoft.com/en-us/library/windows/desktop/bb172341(v=vs.85).aspx . which can probably help out with some management of the textures in video memory.
However, I also would like to know other methods since I couldnt figure out a good way to incorporate managed textures into my code.
My best is to call the Release method of ID3D11ShaderResourceView pointers I store in destructors to prevent filling up the memory , but how do I ensure textures are resting in memory while other apps would want to use it(the memory)?
Windows phone uses Direct3D 11 which 'virtualizes' the GPU memory. Essentially every texture is 'managed'. If you want a detailed description of this, see "Why Your Windows Game Won't Run In 2,147,352,576 Bytes?". The link you provided is Direct3D 9 era for Windows XP XPDM, not any Direct3D 11 capable platform.
It sounds like the key problem is that your application is leaking resources or has too large a working set. You should enable the debug device and first make sure you have cleaned up everything as you expected. You may also want to check that you are following the recommendations for launching/resuming on MSDN. Also keep in mind that Direct3D 11 uses 'deferred destruction' of resources so just because you've called Release everywhere doesn't mean that all the resources are actually gone... To force a full destruction, you need to use Flush.
With Windows phone 8.1 and Direct3D 11.2, there is a specific Trim functionality you can use to reduce an app's memory footprint, but I don't think that's actually your issue.

What contributes to 'Other' section in Native memory snapshot in Chrome developer tools?

As I load more data into my application, 'Other' section keeps growing in my web app. What does this mean? I have checked my code for any memory leaks and couldn't find any. Also, the objects I hold in my application are very much needed for the application.
Varunkumar Nagarajan
How do you checking your app for a leak?
Have you seen Tool to track down JavaScript memory leak
Native memory snapshot is an experimental feature and couldn't be used for detecting memory leaks at the moment.

Limitations of work-item load in GPU? CUDA/OpenCL

I have a compute-intensive image algorithm that, for each pixel, needs to read many distant pixels. The distance is dependent on a constant defined at compile-time. My OpenCL algorithm performs well, but at a certain maximum distance - resulting in more heavy for loops - the driver seems to bail out. The screen goes black for a couple of seconds and then the command queue never finishes. A balloon message reveals that the driver is unhappy:
"Display driver AMD driver stopped responding and has successfully recovered."
(Running this on OpenCL 1.1 with an AMD FirePro V4900 (FireGL V) Graphics Adapter.)
Why does this occur?
Is it possible to, beforehand, tell the driver that everything is ok?
This is a known "feature" under Windows (not sure about Linux) - if the video driver stops responding, the OS will reset it. Except that, since OpenCL (and CUDA) is implemented by the driver, a kernel that takes too long will look like a frozen driver. There is a watchdog timer that keeps track of this (5 seconds, I believe).
Your options are:
You need to make sure that your kernels are not too time-consuming (best).
You can turn-off the watchdog timer: Timeout Detection and Recovery of GPUs.
You can run the kernel on a GPU that is not hooked up to a display.
I suggest you go with 1.

Memory Problems with ActionScript

I am having trouble with memory allocation during a stress/performance testing of a program. In the test, I tried to do loading/unloading same set of resources again and again. The error I got was "Error, #1000, out of memory". The stack trace was about URLLoader/onComplete and URLStream/readBytes. I checked the memory being used at the time of failure, it was less than the maximum amount that the program has used before. I don't think it's caused by memory leak because the memory used through time is pretty consistent (allocate when loading resources, deallocate, allocate, ...) Also, this problem happens kinda randomly. I am kind of stuck. Any suggestions?
If you are using Flex Builder, use the flex profiler to get a better idea of memory being used by various objects.
You can also monitor memory consumption with something as simple as ProcessExplore for Windows or Activity Monitor for Mac. If all you're doing is loading/unloading resources, and you are managing the life of these resources correctly (i.e. removing listeners, making available for garbage collection, etc), then you should see a very consistent peak/valley memory graph. If the memory continues to rise, you've got a leak. Be especially careful if the resources you are loading/unloading are bitmaps as bitmapdata tends to be a prime culprit in flash memory leaks. Good luck!