Can you please let me know if we add a image of 10 MB in the output stream and then donot close and flush it then it will be there in the JVM and if the concurrent user (around 200) doing the same operation (viewing the image) for a long time then the memory usage (occupied by the stream object) will be high and it might lead to Out of memory exception.
Well I would say, over here closing/not closing stream could not be cause of out of Memory. most of output stream source code does not do anything while you close stream. it is blank implemented in sub classes.
And look for your example, that depends on the scope where image is being created/loaded.
If it is per user (per request) a different instance, will reach max usage of memory 200*10 = 2000 MB (~2GB).
is this right?
either look for current memory allocated to your JVM?
further analysis you need a tool like JProve etc or try to check jheap and jstate map to see which and how many objects are lying in the memory with this operation.