Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2017-05-22 02:42:36 -0400
committerEike Stepper2017-05-22 02:42:36 -0400
commit2cb4a4dfe5f5e0e1efd3311205dec6e30bf6292d (patch)
tree6679c30ff3da07c88ed9c4f2798ce76cc460d85c
parent2fcbde92d9cad912cbcc68c81a14a04bb849a5ea (diff)
downloadcdo-2cb4a4dfe5f5e0e1efd3311205dec6e30bf6292d.tar.gz
cdo-2cb4a4dfe5f5e0e1efd3311205dec6e30bf6292d.tar.xz
cdo-2cb4a4dfe5f5e0e1efd3311205dec6e30bf6292d.zip
[478253] java.lang.OutOfMemoryError: Direct buffer memory
https://bugs.eclipse.org/bugs/show_bug.cgi?id=478253
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java95
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBufferProvider.java42
2 files changed, 132 insertions, 5 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java
index 40f2949e38..96ed5f6531 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/buffer/BufferProvider.java
@@ -12,12 +12,14 @@ package org.eclipse.internal.net4j.buffer;
import org.eclipse.net4j.buffer.IBuffer;
import org.eclipse.net4j.buffer.IBufferProvider;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.event.Notifier;
/**
* @author Eike Stepper
*/
-public abstract class BufferProvider extends Lifecycle implements IBufferProvider.Introspection
+public abstract class BufferProvider extends Notifier implements IBufferProvider.Introspection, IBufferProvider.Notification
{
private short bufferCapacity;
@@ -47,14 +49,28 @@ public abstract class BufferProvider extends Lifecycle implements IBufferProvide
public final IBuffer provideBuffer()
{
+ IBuffer buffer = doProvideBuffer();
++providedBuffers;
- return doProvideBuffer();
+
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new BufferProviderEvent.Provided(this, buffer), listeners);
+ }
+
+ return buffer;
}
public final void retainBuffer(IBuffer buffer)
{
- ++retainedBuffers;
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new BufferProviderEvent.Retaining(this, buffer), listeners);
+ }
+
doRetainBuffer(buffer);
+ ++retainedBuffers;
}
@Override
@@ -66,4 +82,75 @@ public abstract class BufferProvider extends Lifecycle implements IBufferProvide
protected abstract IBuffer doProvideBuffer();
protected abstract void doRetainBuffer(IBuffer buffer);
+
+ /**
+ * @author Eike Stepper
+ */
+ protected static abstract class BufferProviderEvent extends Event
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final IBuffer buffer;
+
+ public BufferProviderEvent(IBufferProvider.Notification bufferProvider, IBuffer buffer)
+ {
+ super(bufferProvider);
+ this.buffer = buffer;
+ }
+
+ @Override
+ public IBufferProvider.Notification getSource()
+ {
+ return (IBufferProvider.Notification)super.getSource();
+ }
+
+ public IBuffer getBuffer()
+ {
+ return buffer;
+ }
+
+ @Override
+ protected String formatAdditionalParameters()
+ {
+ return "buffer=" + buffer;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Provided extends BufferProviderEvent implements BufferProvidedEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Provided(IBufferProvider.Notification bufferProvider, IBuffer buffer)
+ {
+ super(bufferProvider, buffer);
+ }
+
+ @Override
+ protected String formatEventName()
+ {
+ return "BufferProvidedEvent";
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Retaining extends BufferProviderEvent implements BufferRetainingEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Retaining(IBufferProvider.Notification bufferProvider, IBuffer buffer)
+ {
+ super(bufferProvider, buffer);
+ }
+
+ @Override
+ protected String formatEventName()
+ {
+ return "BufferRetainingEvent";
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBufferProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBufferProvider.java
index 2c2c0565ec..07875eec8c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBufferProvider.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/IBufferProvider.java
@@ -10,6 +10,9 @@
*/
package org.eclipse.net4j.buffer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.INotifier;
+
/**
* Provides clients with the ability to obtain and retain {@link IBuffer}s.
*
@@ -33,7 +36,7 @@ public interface IBufferProvider
public void retainBuffer(IBuffer buffer);
/**
- * Offers additional introspection features for {@link IBufferProvider}s.
+ * Offers additional introspection features for {@link IBufferProvider buffer providers}.
*
* @author Eike Stepper
*/
@@ -49,4 +52,41 @@ public interface IBufferProvider
*/
public long getRetainedBuffers();
}
+
+ /**
+ * Offers additional notification features for {@link IBufferProvider buffer providers}.
+ *
+ * @author Eike Stepper
+ * @since 4.6
+ */
+ public interface Notification extends IBufferProvider, INotifier
+ {
+ /**
+ * An {@link IEvent event} fired from a {@link IBufferProvider buffer provider} to indicate that a buffer has been provided.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface BufferProvidedEvent extends IEvent
+ {
+ public IBufferProvider.Notification getSource();
+
+ public IBuffer getBuffer();
+ }
+
+ /**
+ * An {@link IEvent event} fired from a {@link IBufferProvider buffer provider} to indicate that a buffer is about to be retained.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface BufferRetainingEvent extends IEvent
+ {
+ public IBufferProvider.Notification getSource();
+
+ public IBuffer getBuffer();
+ }
+ }
}

Back to the top