Android :: References To A Context And Memory Leaks

Jul 27, 2010

I've read that it is a mistake and a source of memory leaks in Android application to keep a long-lived references to a Context.

But I don't understand if it is ok to create an class that looks like this one:

CODE:..........

And call it from an Activity:

CODE:.................

Android :: References to a Context and memory leaks


Android :: Will Code Cause Memory Leaks?

Aug 3, 2010

Will the code cause a memory leak? Essentially I switch between various layouts in my application using setContentView(), and I have member variables of my activity that maintain references to various views (buttons/text views) on the layouts. Am I correct in thinking that if the activity class has a reference to a button and then changes layouts the layout wont be garbage collected because it will still hold a button reference? If this is the case, can I just null the button variable before changing layouts?

View 3 Replies View Related

Android :: How To Find Where Memory Leaks In Activity?

May 20, 2010

When start Activity A, I found the memory usage of application is about 5MB. Then start Activity B from A via startActivity. In Activity B, I created a thread, and traverse file system in this thread, after traversing completed, call finish() and to return to Activity A. At this time, I found the memory usage of application is about 8MB (GC is forced before check memory usage). How to find Where memory leaks? By the way, I checked the memory usage with DDMS.

View 5 Replies View Related

Android :: List View And Memory Leaks

Oct 23, 2010

I have a very simple application which has a problem with getting ListViews to be freed by the GC. i have a ViewGroup which has a ListView. When the page with the ViewGroup no longer has any references to it, and I force a GC, the ListView is not freed. The project in question is quite small and can be found at http://gabysoft.com/download/MemoryLeak.zip. If you run it, the first page has a button and a ListView (which has no items so you cannot see it). When you press the button it switches to a second page which has just a button. When you press the button on the second page, it creates a new ViewGroup and ListView and sets that as the current view. Thus, every time you switch pages, a new ViewGroup/ListView is created, and all references to the old one go away. Hence the old one should be GC'd. However if you switch views 20 times and then force a GC you will see that the ListViews are never freed (i.e. their finalize method (which is logged) is not called). Now here is the really weird part. This happens ONLY if I build my project using Eclipse. If I use Ant to build and install the project, the ListViews are all freed when I do a GC as you would expect. Why would the Eclipse version exhibit this behavior?

View 7 Replies View Related

Android :: Memory Leaks With List View

Oct 20, 2010

I have a class 'GListView' which extends ListView and acts as it's own adapter. It is declared thus: public class GListView extends ListView implements List Adapter In it's constructor, I set it's adapter to itself

View 2 Replies View Related

Android :: Register Callback Leaks Memory?

Mar 5, 2010

I was trying to find out were my apps memory was being leaked and was able to discover that when calling registerCallback(...) it would lead to a memory leak after a screen orientation change. What could be some possible things that are causing the leak? I've tried many things. And I do have a unregisterCallback(..) call.

View 20 Replies View Related

Android :: 'Avoiding Memory Leaks' Article In Blog

Apr 10, 2010

I just read the article 'Avoiding memory leaks' in android blog written by Romain Guy. http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.

View 4 Replies View Related

Android :: Trace Memory / Window Leaks In Droid?

May 17, 2010

How to trace the Memory Leaks in Android Development? I am working on eclipse IDE to develop the application. i cant find out how to rectify the memory or window Leaks Exceptions? Any Idea.

Mainly the Window Leaked error raises the Illegal Argument Exception? how to rectify both og this.

View 1 Replies View Related

Android :: AppWidgets - Reusing RemoteViews Instance Leaks Memory?

May 21, 2009

I'm writing a widget. Currently, I'm have a simple ImageView, and calling RemoteViews.setImageViewBitmap(). I'm using a service to do the updates.

I thought it might be a good idea to reuse an existing RemoteViews instance, so I'm only querying it the first time around, and subsequently simply call setImageViewBitmap() with the new image.

This works well initially, but after some time I first start getting "!!! FAILED BINDER TRANSACTION !!!" errors, and later, an OutOfMemory exception.

Simply creating a new RemoveViews instance every time works flawlessy on the other hand. I'm just curios why that would be, any ideas?

View 2 Replies View Related

General :: How To Find Which Apps Cause Memory Leaks

Apr 22, 2013

Any user friendly android app which can effectively show which apps cause memory leaks on a phone?

I can only find developer tools to detect memory leaks within apps like Eclipse MAT. Sadly I'm not a developer so I would rather prefer just a list of apps to uninstall and not the exact cause of memory leak within a specific app.

View 6 Replies View Related

Android :: Debug Memory Leak Where Exception Instances In Heap Dump Have No Inbound References?

Sep 2, 2010

I've been trying to diagnose a memory leak in an Android application I'm writing. I got a heap dump loaded into Eclipse, but the results I'm seeing are very curious. There are some 20,000 instances of an exception (specifically, LDAPException from the UnboundID LDAP library) in the heap with no inbound references.

That is, they show up at the root of the dominator tree. The OQL SELECT objects e FROM com.unboundid.ldap.sdk.LDAPException e WHERE (inbounds(e).length = 0) returns over 20,000 results, totalling to nearly all of the heap. And yet, the GC runs before the heap dump and I can see that it's running in the console, repeatedly, during the execution of the leaky code. If these instances have no inbound refs, what could be keeping them alive?

I also tried doing a "shortest paths to GC" query. It shows one LDAPConnectionReader row retaining 2 instances, and ~20k LDAPException @ <addr> unknown rows with various hex addresses.

Update: I haven't had time to further diagnose this since posting it, and the bounty I posted is ending before I likely will. I'm awarding it as best I can now, lest the points go to waste. Thanks to everyone who looked into this! I will come back later and update again with the results of further diagnosis, when life is a little less hectic.

View 3 Replies View Related

Android :: Android Tools And Methods Work Best To Find Memory - Resource Leaks

Jul 18, 2009

I've got an Android app developed, and I'm at the point of a phone app development where everything seems to be working well and you want to declare victory and ship, but you know there just have to be some memory and resource leaks in there; and there's only 16mb of heap on the Android and its apparently surprisingly easy to leak in an Android app.

I've been looking around and so far have only been able to dig up info on 'hprof' and 'traceview' and neither gets a lot of favorable reviews.

What tools or methods have you come across or developed and care to share maybe in an OS project?

View 3 Replies View Related

Android :: Android Application Memory Leaks

Dec 23, 2009

I am using kind of results search engine, problem is to remember the searching criteria i made singleton static class which keeps only one instance.In my application there are lots of class level private variables, lots of public static variables, a big util class which contains only static final methods.problem is my application get crash any time any where any spot and interesting thing is crash code always surrounded by try{} catch(Throwable e){} block but never catch, i think it may be memory full issue. I want to discuss one sample case, on the result page i also display result related image, i download image from web and using drawable i place image in the imageview, i created static hashmap to reuse images, some time after downlaod 5 images application crash some times click on a result get user to new detail screen get crash and all code surrounded by try catch block, i am new to mobile program this thing has become night mare to me. Last thing, On emulator hardly application crash but when i try to test the application on device, i am using samsung glaxy android supported to test the application it goes smoth and suddenly it start getting crashed, and after crash android relaunch the activity that throws null pointer exception on every click and caught by try{}catch{} block i think after crashing android dealocate all objects only keep the UI objects thats why when after crash i auto launch the activity clicking causes null pointer exception.how can i stop relaunching crashed activity?

View 1 Replies View Related

Android :: How To Identify Memory Leaks In Android?

Aug 12, 2010

I have developed a simple application before testing it i want to check whether any memory leaks are there in the application. I don't know how to identify the leaks in Android. I am using Eclipse IDE for development. Is there a good introduction into finding memory leaks in Android apps somewhere?

View 2 Replies View Related

Android :: Detecting Memory Leaks In Android

Sep 22, 2010

How to detect Memory leaks in Android JNI code? I am using Froyo

View 1 Replies View Related

Android :: Storing References To ApplicationContext

Apr 20, 2010

I have a static Preferences class that hold some application preferences and stuff like that. Is it ok to store reference to ApplicationContext there? I need that reference so i can get cache folder and stuff like that in classes that don't inherit Activity.

View 1 Replies View Related

Android :: Excessive JNI Global References Seen On 1.5 But Not 2.1

Aug 11, 2010

There's a bug in my network code so that when the server's not available the Android client tries over and over to connect. On 1.5 (emulator) this results, within a minute, in an "Excessive JNI global references" error where the leaked object is a small (20 byte) boolean array. The same code on emulated 2.1 runs for as long as my patience lasts. Is there any possibility the leak is in my code and not an Android bug that's been fixed since 1.5?

View 2 Replies View Related

Android :: Internal String Resource References

Nov 5, 2010

I wonder if it's possible to reference a XML string value in another XML String resource.But in case of an concated resource string, I found no solution yet,I would like to keep the string references in the string.xml file itself.

View 1 Replies View Related

Android :: Passing Around Object References In Java?

Jun 25, 2010

I'm writing some stuff in java and i ran into some problems lately. cut short, i need to compare an object i created to another instance of this very class i instantiazed before with different data.

looks like this:

CODE:........

with a class a:

CODE:..........

The problem is, that i end up finding out that the values from newA are always equal to those from oldA. so i guess sth went wrong with passing the references of the objects in the last line of the loop...i thought java always passes references of objects unless an explicit copy() is called? if this does matter: this code is running on android - don't know if the dalvik vm messes aroung with this...

View 5 Replies View Related

Android :: HTML Resource With References To Other Resources

Jul 21, 2010

I would like to add an HTML resource to my Android project with references to other resources (mainly drawables).

Where should I put it and how do I reference other resources from it?

Is there a particular way to pass the HTML resource to a WebView?

View 2 Replies View Related

Android :: Use SWIG With Droid NDK - Weak Global References

May 11, 2010

I'm currently working on Android NDK, porting my libs, and I'm using SWIG (Simplified Wrapper and Interface Generator) that is a great tool to generate JNI code around my C/C++ headers for Java.

However, there is a big issue using it on Android, 'cause of incomplete JNI support : 'Weak Global References' are missing. Unfortunatly, SWIG is waiting for a full compatible Oracle/Sun JVM, and use this feature with its 'director' option (for proxy class creation).

For now, I comment each time, in a (kind of) bad way, the use of weak global references in my generated C/C++ wrapper files (4 lines in my case). I think it is really a shame that we can't use (one of) the best wrapper with Android NDK just for one missing feature.

I read that Google Team will add it in future release : "NewWeakGlobalRef and DeleteWeakGlobalRef are not implemented. The VM supports weak references, but not JNI "weak global" references. These will be supported in a future release." (http://android.git.kernel.org/?p=platform/ dalvik.git;a=blob_plain;f=docs/jni-tips.html;hb=HEAD)

So my question is, does anybody know when 'Weak Global References' will appear in Android NDK ?

View 4 Replies View Related

Android :: Port Droid To Custom Arm Device / Need References

Nov 24, 2010

I am working on a system on which currently Linux kernel and microwindows windowing system is running. Code of current Linux system drivers is available to me. I want to port android on it, just as a hobby project.

can you please tell me what all understanding of linux-kernel is required to port it?

Please give me references (Books, Tutorials) to build-up understandings.

View 3 Replies View Related

Android :: Tag References Current Theme In Xml Causes Force Close

Oct 27, 2010

I'm in the middle of implementing themes for my application right now, and everything's been going really smooth until as of late. I've been using the android:background="?thin_border" tag to provide a background for linearlayouts with items that I want visually grouped together. The problem I'm running into is when I try to use this tag in an xml with a custom class as one of the elements, and try to add this background tag.

I've got an xml file that looks generally like so:

CODE:.................

and the custom class has two constructors:

CODE:........

with some other functions that store values, manipulate the data, etc. The custom layout class is only ever called directly in the xml, and the xml is inflated like so:

CODE:...........

The problem I'm running into is that I'm getting these error messages:

CODE:.................

The error seems to be caused by the android:background="?thin_border" tag. If I remove it from the layout, it inflates fine, and the program continues on. As soon as I add it back in, I get these errors and the program stops.

View 2 Replies View Related

Android :: Unresolvable References - Paused Analog Clock

Mar 14, 2010

I need to create paused analog clock. Since I have never done any graphics/drawing before I am customizing Analogue widget defined in the core/java/android/widget.

The problem is when I create the class in my project following are the unresolved references: mContext com.android.internal.R mRight mLeft mTop mBottom

I know the most likely cause is com.android.internal is private and I need to use public but the problem I do not know what the public equivalent is. I have tried substituing it with android.R but that doesn't seem work either.

View 2 Replies View Related

Android :: Safely Pass Object References To New Activities?

Dec 8, 2009

I'm working on an application that requires non-serializable objects to be passed between Activities. The following page suggests using a HashMap of WeakReferences to accomplish this:

http://developer.android.com/guide/appendix/faq/framework.html

Is this solution safe? I know Activities are completely destroyed and recreated when the screen orientation changes. Couldn't those weakly referenced objects get GCed in the split second when the screen is rotated, since they wouldn't be referenced elsewhere at that point?

View 3 Replies View Related

Android :: Keeping References To Inflated Custom Views

Apr 26, 2010

While researching how to create custom compound views in Android, I have come across this pattern a lot (example comes from the Jteam blog)I mostly understand how this is working, except for the part where inflate() is called. The documentation says that this method returns a View object, but in this example the author does not store the result anywhere. After inflation, how is the new View created fromt eh XML associated with this class? I thought about assigning it to "this", but that seems very wrong.

View 1 Replies View Related

Android : Good Material On Threads - Couldn't Find References For A Complete Description

Apr 17, 2010

I'm searching for some good material on android threads but I couldn't find references for a complete description about this subject. So if you know any valuable reference please point them to me.

View 1 Replies View Related

Motorola Droid :: Where Are RC 2.2 Leaks?

Jun 19, 2010

Is it just me, or does it seem like it's been, what, a couple months since the last Froyo RC leak? Ok, maybe more like several days, but aren't you guys starting to jones hard for a newer 2.2 leak? When the first couple came out so quickly one after the other (along with the multiple new baseband versions) it seemed like it was going to be raining Froyo leaks (that sounds odd, doesn't it?) on an almost daily basis. I'm running well on BB Froyo v.2.0 plain vanilla, but looking forward to the next 2.2 RC to stumble out of Moto/Verizon's castle so we can continue the informal beta testing for them.

View 15 Replies View Related

HTC Droid Eris :: New Hboot For 2.1 Leaks

May 23, 2010

I have been messing with my eris. I held the power and send button and as usual it checked the leak file and asked if I wanted to update. At this time I noticed a list from one to four., one thing that was listed was bootloader and another was hboot My question would there be a way to get into the 2.1 leak file and some how switch the hboot and bootloader in it with the hboot and bootloader that is on the official ota file or some other jnoot or bootloader. Then convert it back to a zip file and reinstalling it like out was a v4 leak. Sorry if this was a stupid post but just trying to help leak users or devs brainstorm a little.

View 5 Replies View Related

HTC EVO 4G :: Light Leaks On Ebay Phone

Jul 2, 2010

I bought an EVO off of Ebay about a week or so ago and just noticed my light leakage is getting pretty bad. I have sprints insurance on it so I was wondering a few things.

1. Will it be a pain to turn it in for a new phone, and what do I have to pay to do so...I'm guessing they will send me a new one then I'll mail mine back to them>?

2. Would it be the smarter thing to do to wait just a little bit to see the new builds? I'm using a 0003 with a nova screen.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved