This Handler class should be static or leaks might occur: IncomingHandler

I’m developing an Android 2.3.3 application with a service. I have this inside that service to communicate with Main activity: public class UDPListenerService extends Service { private static final String TAG = “UDPListenerService”; //private ThreadGroup myThreads = new ThreadGroup(“UDPListenerServiceWorker”); private UDPListenerThread myThread; /** * Handler to communicate from WorkerThread to service. */ private Handler mServiceHandler; … Read more

When exactly is it leak safe to use (anonymous) inner classes?

I have been reading some articles on memory leaks in Android and watched this interesting video from Google I/O on the subject. Still, I don’t fully understand the concept, and especially when it is safe or dangerous to user inner classes inside an Activity. This is what I understood: A memory leak will occur if … Read more

What is private bytes, virtual bytes, working set?

I am trying to use the perfmon windows utility to debug memory leaks in a process. This is how perfmon explains the terms: Working Set is the current size, in bytes, of the Working Set of this process. The Working Set is the set of memory pages touched recently by the threads in the process. … Read more

Dealing with “java.lang.OutOfMemoryError: PermGen space” error

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It’s a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a few times. What causes it and what can be done to avoid it? How do I fix the problem? … Read more

Activity has leaked window that was originally added

What is this error, and why does it happen? 05-17 18:24:57.069: ERROR/WindowManager(18850): Activity com.mypkg.myP has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 that was originally added here 05-17 18:24:57.069: ERROR/WindowManager(18850): android.view.WindowLeaked: Activity ccom.mypkg.myP has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 that was originally added here 05-17 18:24:57.069: ERROR/WindowManager(18850): at android.view.ViewRoot.<init>(ViewRoot.java:231) 05-17 18:24:57.069: ERROR/WindowManager(18850): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148) 05-17 18:24:57.069: ERROR/WindowManager(18850): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 05-17 18:24:57.069: … Read more

performSelector may cause a leak because its selector is unknown

I’m getting the following warning by the ARC compiler: “performSelector may cause a leak because its selector is unknown”. Here’s what I’m doing: [_controller performSelector:NSSelectorFromString(@”someMethod”)]; Why do I get this warning? I understand the compiler can’t check if the selector exists or not, but why would that cause a leak? And how can I change … Read more