18

I switched to Google App Engine Java SDK 1.7.3 recently. Since then, I am running out of PermGen space every time I am submitting DeferredTasks into the task queue.

  • This does not happen when the app is deployed to App Engine. It only happens locally. But it is blocking my local testing and failing integration tests.
  • It is happening on MacOSX 10.7.5 with Java 6

    $ java -version 
    java version "1.6.0_37"
    Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
    Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
    
  • And this is part of stacktrace I am seeing when the problem occurs.

    INFO: Successfully processed ../target/projectName/WEB-INF/queue.xml
    Nov 1, 2012 3:04:00 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue init
    INFO: LocalTaskQueue is initialized
    Nov 1, 2012 3:04:01 PM org.quartz.simpl.SimpleThreadPool initialize
    INFO: Job execution threads will use class loader of thread: 1255545583@qtp-1458850232-0
    Nov 1, 2012 3:04:02 PM org.quartz.core.QuartzScheduler <init>
    INFO: Quartz Scheduler v.UNKNOWN.UNKNOWN.UNKNOWN created.
    Nov 1, 2012 3:04:02 PM org.quartz.simpl.RAMJobStore initialize
    INFO: RAMJobStore initialized.
    Nov 1, 2012 3:04:02 PM org.quartz.impl.StdSchedulerFactory instantiate
    INFO: Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
    Nov 1, 2012 3:04:02 PM org.quartz.impl.StdSchedulerFactory instantiate
    INFO: Quartz scheduler version: UNKNOWN.UNKNOWN.UNKNOWN
    Nov 1, 2012 3:04:02 PM org.quartz.core.QuartzScheduler start
    INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
    Nov 1, 2012 3:04:02 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue start_
    INFO: Local task queue initialized with base url http://localhost:8083
    Exception in thread "DefaultQuartzScheduler_Worker-9" java.lang.OutOfMemoryError: PermGen space
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:92)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
            at com.google.appengine.api.urlfetch.URLFetchServicePb$URLFetchRequest.newBuilder(URLFetchServicePb.java:1902)
            at com.google.appengine.api.taskqueue.dev.UrlFetchJob.newFetchRequest(UrlFetchJob.java:152)
            at com.google.appengine.api.taskqueue.dev.UrlFetchJob.execute(UrlFetchJob.java:83)
            at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
            at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
    Exception in thread "1255545583@qtp-1458850232-0" java.lang.OutOfMemoryError: PermGen space
    Exception in thread "Timer-6" java.lang.OutOfMemoryError: PermGen space
    Exception in thread "Timer-4" java.lang.OutOfMemoryError: PermGen space
    Exception in thread "Timer-2" java.lang.OutOfMemoryError: PermGen space
    Exception in thread "Timer-8" java.lang.OutOfMemoryError: PermGen space
    

See below for the code that triggers the issue. The DeferredTask has a memcache reference to get data from memcache and potentially remove it. The task is running with a delay of 10 seconds.

class Foo {
    private void enqueueTask() {
        queue.add(TaskOptions.Builder.withPayload(new Task()).countdownMillis(10 * 1000));
    }

    private static class Task implements DeferredTask {
        private static final MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();
        private static final Logger log = Logger.getLogger(Task.class.getName());

        @Override
        public void run() {
            final String key = ...;

            if (memcache.contains(key)) {
                final Object value = memcache.get(key);

                if (some condition depending on value) {
                    memcache.delete(key);
                    memcache.increment(some other field, -1l);
                }
            } else {
                log.warning("error message");
            }
        }
    }
}

Can somebody else reproduce this? Thanks!

Update: I created issue 8377 for this on the GAE's Google Code page.

Ingo
  • 1,552
  • 10
  • 31
  • 4
    Why do not you just increase an amount of memory using XXMaxPermSize JVM arg? – Kirill Lebedev Nov 01 '12 at 21:16
  • 2
    First of all, I think that something is going wrong in my app / GAE itself. **I am doing nothing special and would like to understand why I am running out of PermGen space. I am literally starting GAE and invoke one URL which adds a DeferredTask.** Secondly, I am using the maven-gae-plugin. And both (1) adding XXMaxPermSize to the **MAVEN_OPTS** and (2) adding it to .. of maven-gae-plugin does not change the size of the PermGen space. This is not being picked up by the JVM started by Maven to run GAE. – Ingo Nov 01 '12 at 23:36
  • 1
    How would we increase the PermGen space when running within GAE? Is that even possible? – Ingo Jan 09 '13 at 20:57
  • 2
    You can not change instance config on server. You can do it only for local development environment. – Kirill Lebedev Jan 10 '13 at 17:40
  • [just a helpful pointer](http://stackoverflow.com/questions/13915341/appengine-maven-plugin-configuration-options-like-jvm-flags) – Siva Tumma Jan 18 '14 at 01:07
  • Could you report your current limit of MaxPermSize? – zeppaman Apr 29 '14 at 06:09
  • [Possible fix on the way](http://code.google.com/p/googleappengine/issues/detail?id=8377#c16) – indivisible Apr 29 '14 at 09:04

1 Answers1

2

This isssue was resolved Aug 12, 2014 in the 1.9.6 AppEngine SDK release. MaxPermSize can only be set on the local dev server.

Bogdan.Nourescu
  • 905
  • 6
  • 17