Search in sources :

Example 1 with AppScheduledExecutorService

use of com.intellij.util.concurrency.AppScheduledExecutorService in project intellij-community by JetBrains.

the class ApplicationImpl method dispose.

@Override
public void dispose() {
    HeavyProcessLatch.INSTANCE.stopThreadPrioritizing();
    fireApplicationExiting();
    ShutDownTracker.getInstance().ensureStopperThreadsFinished();
    disposeComponents();
    AppScheduledExecutorService service = (AppScheduledExecutorService) AppExecutorUtil.getAppScheduledExecutorService();
    service.shutdownAppScheduledExecutorService();
    super.dispose();
    // dispose it last
    Disposer.dispose(myLastDisposable);
    if (gatherStatistics) {
        //noinspection TestOnlyProblems
        LOG.info(writeActionStatistics());
        LOG.info(ActionUtil.ActionPauses.STAT.statistics());
        //noinspection TestOnlyProblems
        LOG.info(((AppScheduledExecutorService) AppExecutorUtil.getAppScheduledExecutorService()).statistics() + "; ProcessIOExecutorService threads: " + ((ProcessIOExecutorService) ProcessIOExecutorService.INSTANCE).getThreadCounter());
    }
}
Also used : ProcessIOExecutorService(com.intellij.execution.process.ProcessIOExecutorService) AppScheduledExecutorService(com.intellij.util.concurrency.AppScheduledExecutorService)

Example 2 with AppScheduledExecutorService

use of com.intellij.util.concurrency.AppScheduledExecutorService in project intellij-community by JetBrains.

the class _LastInSuiteTest method testProjectLeak.

public void testProjectLeak() throws Exception {
    boolean guiTestMode = Boolean.getBoolean("idea.test.guimode");
    if (guiTestMode) {
        final Application application = ApplicationManager.getApplication();
        TransactionGuard.getInstance().submitTransactionAndWait(() -> {
            IdeEventQueue.getInstance().flushQueue();
            ((ApplicationImpl) application).exit(true, true, false);
        });
        ShutDownTracker.getInstance().waitFor(100, TimeUnit.SECONDS);
        return;
    }
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        try {
            LightPlatformTestCase.initApplication();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        PlatformTestUtil.cleanupAllProjects();
        ApplicationImpl application = (ApplicationImpl) ApplicationManager.getApplication();
        System.out.println(application.writeActionStatistics());
        System.out.println(ActionUtil.ActionPauses.STAT.statistics());
        System.out.println(((AppScheduledExecutorService) AppExecutorUtil.getAppScheduledExecutorService()).statistics());
        System.out.println("ProcessIOExecutorService threads created: " + ((ProcessIOExecutorService) ProcessIOExecutorService.INSTANCE).getThreadCounter());
        application.setDisposeInProgress(true);
        LightPlatformTestCase.disposeApplication();
        UIUtil.dispatchAllInvocationEvents();
    });
    try {
        LeakHunter.checkProjectLeak();
        Disposer.assertIsEmpty(true);
    } catch (AssertionError | Exception e) {
        captureMemorySnapshot();
        throw e;
    }
    try {
        Disposer.assertIsEmpty(true);
    } catch (AssertionError | Exception e) {
        captureMemorySnapshot();
        throw e;
    }
}
Also used : AppScheduledExecutorService(com.intellij.util.concurrency.AppScheduledExecutorService) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) Application(com.intellij.openapi.application.Application)

Example 3 with AppScheduledExecutorService

use of com.intellij.util.concurrency.AppScheduledExecutorService in project intellij-community by JetBrains.

the class PerformanceWatcher method initComponent.

@Override
public void initComponent() {
    if (shouldWatch()) {
        final AppScheduledExecutorService service = (AppScheduledExecutorService) AppExecutorUtil.getAppScheduledExecutorService();
        service.setNewThreadListener(new Consumer<Thread>() {

            private final int ourReasonableThreadPoolSize = Registry.intValue("core.pooled.threads");

            @Override
            public void consume(Thread thread) {
                if (service.getBackendPoolExecutorSize() > ourReasonableThreadPoolSize && ApplicationInfoImpl.getShadowInstance().isEAP()) {
                    File file = dumpThreads("newPooledThread/", true);
                    LOG.info("Not enough pooled threads" + (file != null ? "; dumped threads into file '" + file.getPath() + "'" : ""));
                }
            }
        });
        ApplicationManager.getApplication().executeOnPooledThread(() -> cleanOldFiles(myLogDir, 0));
        for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
            if ("Code Cache".equals(bean.getName())) {
                watchCodeCache(bean);
                break;
            }
        }
    }
}
Also used : AppScheduledExecutorService(com.intellij.util.concurrency.AppScheduledExecutorService) MemoryPoolMXBean(java.lang.management.MemoryPoolMXBean) File(java.io.File)

Aggregations

AppScheduledExecutorService (com.intellij.util.concurrency.AppScheduledExecutorService)3 ProcessIOExecutorService (com.intellij.execution.process.ProcessIOExecutorService)1 Application (com.intellij.openapi.application.Application)1 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)1 File (java.io.File)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1