Memory leak?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory leak?

mschipperheyn
Hi,

I'm doing some memory leak analysis on our system that uses Spring,
Hibernate, Hibernate Search and Freemarker.

In one of our heapdumps, freemarker.core.InvalidReferenceException
popped up as participating in a Leak Suspect.
Looking at the way TemplateExceptions are handled and the
Environment that is stored in them, I am wondering if this isn't a
potential cause for memory leaks. Does the Environment reference the
surrounding Environment, in my case Spring?

I'm not sure about this, but I thought it would be interesting
to bring it up.

Marc


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak?

Daniel Dekany
As the Environment refers to the data-model (template context), it can
indirectly hold reference to pretty much anything. Why's the
TemplateException kept alive though?

--
Thanks,
 Daniel Dekany


Saturday, November 16, 2013, 9:23:40 PM, Marc Schipperheyn wrote:

> Hi,
>
> I'm doing some memory leak analysis on our system that uses Spring,
> Hibernate, Hibernate Search and Freemarker.
>
> In one of our heapdumps, freemarker.core.InvalidReferenceException
> popped up as participating in a Leak Suspect.
> Looking at the way TemplateExceptions are handled and the
> Environment that is stored in them, I am wondering if this isn't a
> potential cause for memory leaks. Does the Environment reference the
> surrounding Environment, in my case Spring?
>
> I'm not sure about this, but I thought it would be interesting
> to bring it up.
>
> Marc


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak?

mschipperheyn
Hi Daniel,
I have attached a screenshot. It's held alive by a quartz scheduled worker thread Inline image 2through the classloader..Inline image 1

Vriendelijke groet,

Marc

M.Schipperheyn



MSW BV | Nova Zemblastraat 12-a, 1013 RK, Amsterdam | KvK: 02090184
skype: mschipperheyn | Twitter: mschipperheyn
Netherlands: m: +31 (0)6 218 03 003 | t: +31 (0)84 88 453 99
Brazil: m: +55 (0)11 99 44 6 3472


On Sat, Nov 16, 2013 at 8:14 PM, Daniel Dekany <[hidden email]> wrote:
As the Environment refers to the data-model (template context), it can
indirectly hold reference to pretty much anything. Why's the
TemplateException kept alive though?

--
Thanks,
 Daniel Dekany


Saturday, November 16, 2013, 9:23:40 PM, Marc Schipperheyn wrote:

> Hi,
>
> I'm doing some memory leak analysis on our system that uses Spring,
> Hibernate, Hibernate Search and Freemarker.
>
> In one of our heapdumps, freemarker.core.InvalidReferenceException
> popped up as participating in a Leak Suspect.
> Looking at the way TemplateExceptions are handled and the
> Environment that is stored in them, I am wondering if this isn't a
> potential cause for memory leaks. Does the Environment reference the
> surrounding Environment, in my case Spring?
>
> I'm not sure about this, but I thought it would be interesting
> to bring it up.
>
> Marc



------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak?

Daniel Dekany
OK, but for what purpose does it have to keep that Exception instance
for prolonged time? Isn't that the real memory leak?

--
Thanks,
 Daniel Dekany


Saturday, November 16, 2013, 11:26:53 PM, Marc Schipperheyn wrote:

> Hi Daniel,
> I have attached a screenshot. It's held alive by a quartz scheduled
> worker thread  through the classloader..
>
> Vriendelijke groet,
>
> Marc
>
> M.Schipperheyn
>
>  
>
> MSW BV | Nova Zemblastraat 12-a, 1013 RK, Amsterdam | KvK: 02090184
> skype: mschipperheyn | Twitter: mschipperheyn
> Netherlands: m: +31 (0)6 218 03 003 | t: +31 (0)84 88 453 99
> Brazil: m: +55 (0)11 99 44 6 3472
>
>
> On Sat, Nov 16, 2013 at 8:14 PM, Daniel Dekany <[hidden email]> wrote:
> As the Environment refers to the data-model (template context), it can
> indirectly hold reference to pretty much anything. Why's the
> TemplateException kept alive though?
>
> --
> Thanks,
>  Daniel Dekany
>
>
> Saturday, November 16, 2013, 9:23:40 PM, Marc Schipperheyn wrote:
>
>> Hi,
>>
>> I'm doing some memory leak analysis on our system that uses Spring,
>> Hibernate, Hibernate Search and Freemarker.
>>
>> In one of our heapdumps, freemarker.core.InvalidReferenceException
>> popped up as participating in a Leak Suspect.
>> Looking at the way TemplateExceptions are handled and the
>> Environment that is stored in them, I am wondering if this isn't a
>> potential cause for memory leaks. Does the Environment reference the
>> surrounding Environment, in my case Spring?
>>
>> I'm not sure about this, but I thought it would be interesting
>> to bring it up.
>>
>> Marc
>
>


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak?

mschipperheyn
You're prob right. I always find it hard to do these memory leak analysis. Although keeping a reference to the entire context in an Exception somehow feels wrong. 

Cheers,
Marc

Vriendelijke groet,

Marc

M.Schipperheyn



MSW BV | Nova Zemblastraat 12-a, 1013 RK, Amsterdam | KvK: 02090184
skype: mschipperheyn | Twitter: mschipperheyn
Netherlands: m: +31 (0)6 218 03 003 | t: +31 (0)84 88 453 99
Brazil: m: +55 (0)11 99 44 6 3472


On Sun, Nov 17, 2013 at 10:28 AM, Daniel Dekany <[hidden email]> wrote:
OK, but for what purpose does it have to keep that Exception instance
for prolonged time? Isn't that the real memory leak?

--
Thanks,
 Daniel Dekany


Saturday, November 16, 2013, 11:26:53 PM, Marc Schipperheyn wrote:

> Hi Daniel,
> I have attached a screenshot. It's held alive by a quartz scheduled
> worker thread  through the classloader..
>
> Vriendelijke groet,
>
> Marc
>
> M.Schipperheyn
>
>
>
> MSW BV | Nova Zemblastraat 12-a, 1013 RK, Amsterdam | KvK: 02090184
> skype: mschipperheyn | Twitter: mschipperheyn
> Netherlands: m: <a href="tel:%2B31%20%280%296%20218%2003%20003" value="+31621803003">+31 (0)6 218 03 003 | t: <a href="tel:%2B31%20%280%2984%2088%20453%2099" value="+31848845399">+31 (0)84 88 453 99
> Brazil: m: <a href="tel:%2B55%20%280%2911%2099%2044%206%203472" value="+5511994463472">+55 (0)11 99 44 6 3472
>
>
> On Sat, Nov 16, 2013 at 8:14 PM, Daniel Dekany <[hidden email]> wrote:
> As the Environment refers to the data-model (template context), it can
> indirectly hold reference to pretty much anything. Why's the
> TemplateException kept alive though?
>
> --
> Thanks,
>  Daniel Dekany
>
>
> Saturday, November 16, 2013, 9:23:40 PM, Marc Schipperheyn wrote:
>
>> Hi,
>>
>> I'm doing some memory leak analysis on our system that uses Spring,
>> Hibernate, Hibernate Search and Freemarker.
>>
>> In one of our heapdumps, freemarker.core.InvalidReferenceException
>> popped up as participating in a Leak Suspect.
>> Looking at the way TemplateExceptions are handled and the
>> Environment that is stored in them, I am wondering if this isn't a
>> potential cause for memory leaks. Does the Environment reference the
>> surrounding Environment, in my case Spring?
>>
>> I'm not sure about this, but I thought it would be interesting
>> to bring it up.
>>
>> Marc
>
>



------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak?

Daniel Dekany
I'm not sure if that's bad or not. I can't change that for backward
compatibility reasons anyway, it's just an interesting question. As
far as I know, the reason Exceptions usually don't hold complex
objects is that they should be serializable. TemplateException-s just
drop the Environment when they are serialized, as the exception object
itself works with null Environment too.

Regards,
  Daniel


Sunday, November 17, 2013, 1:33:18 PM, Marc Schipperheyn wrote:

> You're prob right. I always find it hard to do these memory leak
> analysis. Although keeping a reference to the entire context in an Exception somehow feels wrong.
>
> Cheers,
> Marc
>
> Vriendelijke groet,
>
> Marc
>
> M.Schipperheyn
>
>  
>
> MSW BV | Nova Zemblastraat 12-a, 1013 RK, Amsterdam | KvK: 02090184
> skype: mschipperheyn | Twitter: mschipperheyn
> Netherlands: m: +31 (0)6 218 03 003 | t: +31 (0)84 88 453 99
> Brazil: m: +55 (0)11 99 44 6 3472
>
>
> On Sun, Nov 17, 2013 at 10:28 AM, Daniel Dekany <[hidden email]> wrote:
> OK, but for what purpose does it have to keep that Exception instance
> for prolonged time? Isn't that the real memory leak?
>
> --
> Thanks,
>  Daniel Dekany
>
>
> Saturday, November 16, 2013, 11:26:53 PM, Marc Schipperheyn wrote:
>
>> Hi Daniel,
>> I have attached a screenshot. It's held alive by a quartz scheduled
>> worker thread  through the classloader..
>>
>> Vriendelijke groet,
>>
>> Marc
>>
>> M.Schipperheyn
>>
>>
>>
>> MSW BV | Nova Zemblastraat 12-a, 1013 RK, Amsterdam | KvK: 02090184
>> skype: mschipperheyn | Twitter: mschipperheyn
>> Netherlands: m: +31 (0)6 218 03 003 | t: +31 (0)84 88 453 99
>> Brazil: m: +55 (0)11 99 44 6 3472
>>
>>
>> On Sat, Nov 16, 2013 at 8:14 PM, Daniel Dekany <[hidden email]> wrote:
>> As the Environment refers to the data-model (template context), it can
>> indirectly hold reference to pretty much anything. Why's the
>> TemplateException kept alive though?
>>
>> --
>> Thanks,
>>  Daniel Dekany
>>
>>
>> Saturday, November 16, 2013, 9:23:40 PM, Marc Schipperheyn wrote:
>>
>>> Hi,
>>>
>>> I'm doing some memory leak analysis on our system that uses Spring,
>>> Hibernate, Hibernate Search and Freemarker.
>>>
>>> In one of our heapdumps, freemarker.core.InvalidReferenceException
>>> popped up as participating in a Leak Suspect.
>>> Looking at the way TemplateExceptions are handled and the
>>> Environment that is stored in them, I am wondering if this isn't a
>>> potential cause for memory leaks. Does the Environment reference the
>>> surrounding Environment, in my case Spring?
>>>
>>> I'm not sure about this, but I thought it would be interesting
>>> to bring it up.
>>>
>>> Marc
>>
>>
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel