Strange native leak - OutOfMemory after language change.

by Pedro Oliveira » Tue, 25 Jan 2011 02:51:09 GMT


Sponsored Links
 Hi.

I am facing a strange native memory leak in my application, can
someone help me please?

The leak heppens after change the language of the phone in settings.
Before changing the language, I have just opened the application and
ran dumpsys meminfo in the process. The result was that the process
had 18495 KB total memory allocated, which were 11704 KB native and
6791 KB dalvik.

After changin language for the first time, opening the app again and
running dumpsys meminfo onge more time, the result was that the
process had 24115 KB total memory allocated, which were 17324 KB
native and 6791 KB dalvik.

Looking the heap size in DDMS I saw the process had a total of 6 MB,
which makes sense with the 6791KB of dalvik memory allocated. Changing
the language again makes the total allocated memory grow, getting to
29335 total memory allocated, which were 22544 KB native and 6791 KB
dalvik.

As you can see, it is only the native part that grows, therefore using
Eclipse MAT on the generated HPROF file does not give any good leak
suspects.

We are passing the application context instead of the activity context
as explained in the article 
 http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html 

I compared the results with other applications in the phone, and saw
that it is common to the memory allocated to grow in the first time
the language is changed, but the amount of memory is kept unchanged in
the subsequent changes for those other applications.

I also read that "DDMS does not report memory that is allocated on
your behalf on the native side", but than, how can I make sure that
memory will be freed? Also, the content of the native memory must be
connected to the dalvik amount of memory, how can I find that
connection??

I am getting out of ideas, did anyone see something similar or have
any hints for me?

Thanks in advance!!
Cheers!!
Pedro

-- 



Other Threads

1. Is there way to create a slow motion method for video

Is there way to create a slow motion method for video?

-- 

2. Announcement: DynaDroid - an open source micro-framework for Android

This post is in reply to the thread "DynaDroid - an open source micro-
framework for Android" found here:

http://www.google.com/url?url=http://groups.google.com/g/ac47fb6d/t/27cdd6c5c3f3b0fc/d/e396a0e909a6c078%3Fq%3Ddynadroid%23e396a0e909a6c078&ei=8iX1TP2nONLTlQfwqsmuCw&sa=t&ct=res&cd=1&source=groups&usg=AFQjCNG2ijPrh45wt5h7a_H1ifGb8d9VwQ

I tried several times to reply over a few months, but the moderators
never approved it.  Here it goes...

Thanks for your sharing your concerns about DynaDroid...they are
definitely warranted...hopefully our answers will shed some light on
things...

- The prompt when exiting and killing the process was a requirement by
our business and we can definitely make that configurable so it's easy
to turn off/on.  Thanks for bringing this up.


DynaDroid is optimized for screen based applications that don't care
about sharing internal screens (or activities) with other apps.  It's
actually a really simple framework that just manages the screen stack
and proxies everything you get on an Activity to the top screen.  This
allows us to have built-in screen analytics and orientation control at
the screen level, and to pass data around like normal Java.  And the
conventions allow you to remove a tremendous amount of wiring and
plumbing.  The way you handle restoring state hasn't changed...and in
fact we are working on a convention to make this even easier.

So all in all with DynaDroid you get a very DRY framework that speeds
up the creation and maintenance of your Android app.  Why should every
developer have to re-invent the niceties you expect to have in screen
based applications?  This is why we opened up DynaDroid to other
developers..so they don't have to.

Best,

Brian

http://www.starterstep.com

-- 

3. Speech Recognition Help

4. Widget Not Updating Display

5. Live WallPaper and TextView

6. Can you detect a touch to the screen when the screen is off? (Wake up screen with a touch)

7. Google Maps API hidden maps and opengl