简体   繁体   中英

ObjectEncoderOutputStream Out Of Memory Exception possible?

I noticed that ObjectEncoderOutputStream uses ObjectOutputStream . Traditionally ObjectOutputStream can cause an OOME if it's not reset on a regular basis. Is ObjectEncoderOutputStream susceptible to this?

No , the ObjectEncoderOutputStream is not susceptible to the same problem, because of the way it uses the ObjectOutputStream .

For each writeObject call a new ObjectOutputStream (specifically a CompactObjectOutputStream ) is created to write that single object and then it is closed again.

Thus, no ObjectOutputStream ever holds on to old references and thus doesn't cause a OOM this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM