JAXBContext.newInstance memory leak

2019-02-06 05:54发布

After a recent deployment in system test, one of our servlets was getting hit much harder than usual and we noticed memory started climbing and weblogic would eventually die. My intern, I was very proud, discovered the source of the memory leak.

Whenever a request comes in, this line gets called:

JAXBContext jc = JAXBContext.newInstance(“ruby.oracle_servlet.schemas”);

For some reason, the object never gets garbage collected. Once we made it static and moved where we initialized it, our memory leak went away.

Another one of our developers put just that line in a while loop in standalone java application and also saw the memory creep up and up.

Does anyone have any ideas why that object doesn't get garbage collected?

Thanks

2条回答
Melony?
2楼-- · 2019-02-06 06:29

Yes, it's a leak. It will load the class “ruby.oracle_servlet.schemas”, every time this method is called.

JAXBContext.newInstance(“ruby.oracle_servlet.schemas”)
查看更多
登录 后发表回答