Hi,
I am recently using Jersey to create a server of code. The idea is
downloading and uploading code using a REST interface. The problem I
have is that doing performance tests, after serving approximately 3000
codes of 70KB each one, the application gets out of memory. I thought it
could happen by a mistake closing the files where the code resides, but
this is an operation which is automatically done by the Jersey, since I
serve this code through an InputStream:
resp = Response.ok(is).type(MediaType.APPLICATION_OCTET_STREAM).build();
where "is" is the InputStream to the file. Then, I read some messages in
the Jersey users newslist and I saw that some time ago there were a
problem closing these streams. Is it possible that this problem has
reappeared now? I am using Jersey 0.7ea. I include the error thrown in
the following lines:
Exception in thread "Thread-2" java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:39)
at java.nio.ByteBuffer.allocate(ByteBuffer.java:312)
at sun.net.httpserver.Request$WriteStream.write(Request.java:383)
at
sun.net.httpserver.ChunkedOutputStream.writeChunk(ChunkedOutputStream
.java:104)
at
sun.net.httpserver.ChunkedOutputStream.write(ChunkedOutputStream.java
:68)
at
sun.net.httpserver.PlaceholderOutputStream.write(ExchangeImpl.java:37
5)
at
com.sun.ws.rest.impl.provider.entity.AbstractMessageReaderWriterProvi
der.writeTo(AbstractMessageReaderWriterProvider.java:65)
at
com.sun.ws.rest.impl.provider.entity.InputStreamProvider.writeTo(Inpu
tStreamProvider.java:66)
at
com.sun.ws.rest.impl.provider.entity.InputStreamProvider.writeTo(Inpu
tStreamProvider.java:37)
at
com.sun.ws.rest.spi.container.AbstractContainerResponse.writeEntity(A
bstractContainerResponse.java:270)
at
com.sun.ws.rest.impl.container.httpserver.HttpServerResponseAdaptor.c
ommitAll(HttpServerResponseAdaptor.java:83)
at
com.sun.ws.rest.impl.container.httpserver.HttpHandlerContainer.handle
(HttpHandlerContainer.java:72)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
at
sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.
java:552)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:524)
at
sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java
:119)
at
sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:349)
at
sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:321)
at java.lang.Thread.run(Thread.java:619)
Thank you for you help,
Jordi.
--
.............................................................
:: Jordi Cucurull Juan :: Phone: +34 93 581 3577
:: (jcucurull_at_deic.uab.cat)
Departament d'Enginyeria de la Informacio i les Comunicacions
Universitat Autonoma de Barcelona - 08193 Bellaterra, Spain
.............................................................