[android-developers] Re: Out of memory and no useful stack trace

2010-04-11 Thread HippoMan
Thanks to both of you. I'm now going to try what each of you
suggested.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.


[android-developers] Re: Out of memory and no useful stack trace

2010-04-11 Thread Nanard
You should at least have an idea/logs on the methods which creates
OOM, you can encapsulate into a :

try  {
bigMethod();
   }
catch(java.lang.OutOfMemoryError e) {
 all objects = null;
System.gc();
System.runFinalization();
   }


Maybe you can also use :
Runtime.getRuntime().freeMemory()
Runtime.getRuntime().maxMemory()
Runtime.getRuntime().totalMemory ()

to know if you have to stop what you are doing : properly.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.


[android-developers] Re: Out of memory and no useful stack trace

2010-04-11 Thread Thilo-Alexander Ginkel
On Apr 11, 3:44 pm, HippoMan  wrote:
> My android app is getting an "Out of memory" error without a useful
> stack trace. It occurs after I have repeatedly re-invoked its main
> logic through a menu interaction, which leads me to believe that
> there's a memory leak somewhere.
>
> I say that the stack trace isn't useful because it doesn't include
> references to any of my own code. There are no references to my own
> code in the logcat output, either.

The problem with OOMs is that the thread/code fragment that will
trigger the OOM is not necessarily the one that leaked memory. This is
probably what you are observing. It is just "bad luck" that the
Android message loop triggers it as it is trying to allocate memory
that has been used up somewhere else.

> I'm wondering if any of you can help me figure out where my memory
> leak might be occurring, given my stack trace and my logcat output.

Why not create a series of heap dumps over time and analyze their
delta using the Eclipse Memory Analyzer (MAT)? That should point out
where the leak is originating from. You will need to convert the
Dalvik heap dump to Sun's .hprof format before MAT can read it.

Regards,
Thilo

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.


[android-developers] Re: Out of memory and no useful stack trace

2010-04-11 Thread Kumar Bibek
OutofMemory errors are very rare and will pop up if you are really
creating too many variables in a short span of time, or you are
creating a really really large object, for instance, a Bitmap object
of a big image file, or while creating a DOM object of a really large
XML.

04-11 09:27:41.931: ERROR/(5262): VM won't let us allocate 345600
bytes

This is where the error starts

May be some more logcat output will help.

Thanks and Regards,
Kumar Bibek.



On Apr 11, 6:44 pm, HippoMan  wrote:
> My android app is getting an "Out of memory" error without a useful
> stack trace. It occurs after I have repeatedly re-invoked its main
> logic through a menu interaction, which leads me to believe that
> there's a memory leak somewhere.
>
> I say that the stack trace isn't useful because it doesn't include
> references to any of my own code. There are no references to my own
> code in the logcat output, either.
>
> I'm wondering if any of you can help me figure out where my memory
> leak might be occurring, given my stack trace and my logcat output.
>
> Here's the stack trace:
>
> Thread [<3> main] (Suspended (exception OutOfMemoryError))
>         ViewRoot.handleMessage(Message) line: 1716
>         ViewRoot(Handler).dispatchMessage(Message) line: 99
>         Looper.loop() line: 123
>         ActivityThread.main(String[]) line: 4203
>         Method.invokeNative(Object, Object[], Class, Class[], Class, int,
> boolean) line: not available [native method]
>         Method.invoke(Object, Object...) line: 521
>         ZygoteInit$MethodAndArgsCaller.run() line: 791
>         ZygoteInit.main(String[]) line: 549
>         NativeStart.main(String[]) line: not available [native method]
>
> ... and here's the logcat output:
>
> [ ... lots of repetitions of the following WARN messages as I
> repeatedly invoke my app's main logic via a menu selection ... ]
> 04-11 09:27:35.341: WARN/InputManagerService(52): Window already
> focused, ignoring focus gain of:
> com.android.internal.view.iinputmethodclient$stub$pr...@4398a268
> 04-11 09:27:35.842: WARN/KeyCharacterMap(5262): No keyboard for id 0
> 04-11 09:27:35.852: WARN/KeyCharacterMap(5262): Using default keymap: /
> system/usr/keychars/qwerty.kcm.bin
> 04-11 09:27:36.852: WARN/InputManagerService(52): Window already
> focused, ignoring focus gain of:
> com.android.internal.view.iinputmethodclient$stub$pr...@439c3f38
> 04-11 09:27:38.782: WARN/InputManagerService(52): Window already
> focused, ignoring focus gain of:
> com.android.internal.view.iinputmethodclient$stub$pr...@43909130
> 04-11 09:27:39.392: WARN/KeyCharacterMap(5262): No keyboard for id 0
> 04-11 09:27:39.392: WARN/KeyCharacterMap(5262): Using default keymap: /
> system/usr/keychars/qwerty.kcm.bin
> 04-11 09:27:40.332: WARN/InputManagerService(52): Window already
> focused, ignoring focus gain of:
> com.android.internal.view.iinputmethodclient$stub$pr...@43996c88
> 04-11 09:27:41.931: ERROR/dalvikvm-heap(5262): 345600-byte external
> allocation too large for this process.
> 04-11 09:27:41.931: ERROR/(5262): VM won't let us allocate 345600
> bytes
>
> Could my error be related to the "Window already focused ..."
> warnings? If so, how can I find out what is causing these?
>
> I know that I could sprinkle my code with lots of calls to Log.v() in
> order to zero in on where my problem might be occurring, but I'm
> wondering if there is a better way to get more meaningful information
> about the cause of my memory leak.
>
> Thanks in advance for any suggestions.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.