Bug 65060 OutOfMemory using Jobs Examples plug-in
build i0529-0105, Linux-Motif - I have the ui.jobs example plug-in loaded from HEAD - I am running a runtime workbench - I ran a couple of examples - then I clicked to create a job with the following stats: - duration 10 sec - 1 job - system job - fail The result was an OOM error. Not much info in the console but here it is. !SESSION Jun 01, 2004 12:52:25.171 --------------------------------------------- eclipse.buildId=unknown java.version=1.4.2_03 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=motif, NL=en_US !ENTRY org.eclipse.core.runtime 4 2 Jun 01, 2004 12:52:25.174 !MESSAGE An internal error occurred during: "Test job". !STACK 0 java.lang.OutOfMemoryError at org.eclipse.ui.examples.jobs.TestJob.run(TestJob.java:60) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66) !ENTRY org.eclipse.ui 4 4 Jun 01, 2004 12:52:25.180 !MESSAGE Unhandled event loop exception !ENTRY org.eclipse.ui 4 0 Jun 01, 2004 12:52:25.182 !MESSAGE java.lang.OutOfMemoryError !STACK 0 java.lang.OutOfMemoryError at org.eclipse.ui.examples.jobs.TestJob.run(TestJob.java:60) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66) Unhandled event loop exception Reason: java.lang.OutOfMemoryError
examples/org.eclipse.ui.examples.job/src/org/eclipse/ui/examples/jobs/TestJob.java
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
	 */
	public IStatus run(IProgressMonitor monitor) {
		if (failure) {
			throw new OutOfMemoryError();
		}
		final long sleep = 10;
		int ticks = (int) (duration / sleep);
		if(this.unknown)
			monitor.beginTask(toString(), IProgressMonitor.UNKNOWN);
		else
			monitor.beginTask(toString(), ticks);
		try {
			for (int i = 0; i < ticks; i++) {
				if (monitor.isCanceled())
					return Status.CANCEL_STATUS;
				monitor.subTask("Processing tick #" + i); 
				try {
					Thread.sleep(sleep);
				} catch (InterruptedException e) {
					Thread.interrupted();
				}
				monitor.worked(1);
			}
		} finally {
			monitor.done();
		}
		return Status.OK_STATUS;
	}
}