By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,791 Members | 1,314 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,791 IT Pros & Developers. It's quick & easy.

Is it good to convert inputstream into byte[] and hold it in memory.

P: 1
Actually in my code i'm going to convert inputstream of some large files (sometimes it'll be 30MB also) into byte array object. I'll reuse this byte array object for some time then i'll destroy it.

Converting inputstream to byte array will create any performance problem for system ? If so please suggest me how to solve it.


Actually in my application, request from client may contain just give part of the content in the file or only give first 1000 bytes of the file content or else last 1000 bytes of the file content or else give full content of the file. So in order to avoid reading file again and again for each request i thought converting inputstream into byte array and hold in memory itself for some time.While i thinking about this idea of converting stream to byte[] will result in shortage of allocated inmemory Because in my application allocated inmemory is 4GB also at the same time we may receive more than 100 requests to server. Whether this will result in OOM error?
May 2 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.