On Thu, Oct 23, 2008 at 6:40 AM,  <nextgens at freenetproject.org> wrote:
> Author: nextgens
> Date: 2008-10-22 22:40:31 +0000 (Wed, 22 Oct 2008)
> New Revision: 23041
>
> Modified:
>   trunk/freenet/src/freenet/client/async/SingleFileInserter.java
> Log:
> serialize compression so that we don't run out of memory


>
> Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
> ===================================================================
> --- trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
> 2008-10-22 22:39:23 UTC (rev 23040)
> +++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
> 2008-10-22 22:40:31 UTC (rev 23041)
[...]
> -       private class OffThreadCompressor implements Runnable {
> +       // Use a mutex to serialize compression (limit memory usage/IO)
> +       // Of course it doesn't make any sense on multi-core systems.
> +       private static final Object compressorSync = new Object();

use java.util.concurrent.Semaphore if you want the number of
concurrent compressor adjustable.

> +
> +       private  class OffThreadCompressor implements Runnable {
>                public void run() {
>                    freenet.support.Logger.OSThread.logPID(this);
>                        try {
> @@ -138,6 +134,7 @@
>        }
>
>        private void tryCompress() throws InsertException {
> +               synchronized(compressorSync) {

Reply via email to