[WIP] Implements reusable sample buffers across all components. This

produces a significant reduction in memory usage, especially for tuners
like the airspy and hackrf that produce 10/20 MSPS sample rates.  This
is observed to be around 66% reduction in peak memory usage and provides
a more stable memory utilization across time reducing stress on the
garbage collector.

Use of these reusable memory buffers will be pushed further down into
the processing chain modules to ensure we keep new object creation
to the lowest levels possible.
This commit is contained in:
Denny
2018-02-03 10:05:16 -05:00
parent fcd3c2fd46
commit f2f2c92afe
56 changed files with 1630 additions and 1255 deletions

View File

@@ -36,9 +36,9 @@ public class OverflowableTransferQueue<E>
private IOverflowListener mOverflowListener;
private Source mSourceOverflowListener;
private LinkedTransferQueue<E> mQueue = new LinkedTransferQueue<E>();
private AtomicInteger mCounter = new AtomicInteger();
private AtomicBoolean mOverflow = new AtomicBoolean();
protected LinkedTransferQueue<E> mQueue = new LinkedTransferQueue<E>();
protected AtomicInteger mCounter = new AtomicInteger();
protected AtomicBoolean mOverflow = new AtomicBoolean();
private int mMaximumSize;
private int mResetThreshold;
@@ -73,6 +73,21 @@ public class OverflowableTransferQueue<E>
setOverflow(true);
}
}
else
{
overflow(e);
}
}
/**
* Invoked when the buffer is in an overflow state. The element argument is thrown away. Override this method
* in subclasses to perform any necessary cleanup action(s).
*
* @param e element that is being thrown away due to an overflow condition
*/
protected void overflow(E e)
{
//No-op. Override in subclass to perform any cleanup actions during overflow
}
/**