Skip to content

[JENKINS-16341] Memory leak in createJavaScriptProxy #13214

Closed

Description

@jenkins-infra-bot

Never seems to release bound objects, even after they have been rendered.


Originally reported by jglick, imported from: Memory leak in createJavaScriptProxy
  • assignee: jglick
  • status: Closed
  • priority: Major
  • component(s): core
  • label(s): 2.528.1-rejected, memory-leak, performance, stapler
  • resolution: Fixed
  • resolved: 2025-09-23T01:48:50+00:00
  • votes: 0
  • watchers: 11
  • imported: 2025-11-24
Raw content of original issue

Never seems to release bound objects, even after they have been rendered.

1 attachment

Activity

  1. jenkins-infra-bot commented on Jan 14, 2013

    @jenkins-infra-bot
    Author
  2. jenkins-infra-bot commented on Jan 14, 2013

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      In Jenkins Enterprise, merely opening the config page for a newly created freestyle job results in >100 RenderOnDemandClosure instances being bound, none of which are ever released.

    In Jenkins Enterprise, merely opening the config page for a newly created freestyle job results in >100 RenderOnDemandClosure instances being bound, none of which are ever released.

  3. jenkins-infra-bot commented on Jan 14, 2013

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      Heap delta in OSS trunk, after ~18 requests from

      curl -I http://localhost:8080/job/x/configure >&-
      

    Heap delta in OSS trunk, after ~18 requests from

    curl -I http://localhost:8080/job/x/configure >&-
    
  4. jenkins-infra-bot commented on Jan 15, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    changelog.html
    core/src/main/java/hudson/widgets/RenderOnDemandClosure.java
    http://jenkins-ci.org/commit/jenkins/08efdf5d3ab962cfd4c4c489266592fe1db7df8e
    Log:
    JENKINS-16341 Amelioration of memory leak by at least interning some heavily redundant strings.

  5. jenkins-infra-bot commented on Jan 15, 2013

    @jenkins-infra-bot
    Author
    dogfood:

    Integrated in jenkins_main_trunk #2190
    JENKINS-16341 Amelioration of memory leak by at least interning some heavily redundant strings. (Revision 08efdf5)

    Result = SUCCESS
    Jesse Glick : 08efdf5d3ab962cfd4c4c489266592fe1db7df8e
    Files :

    • changelog.html
    • core/src/main/java/hudson/widgets/RenderOnDemandClosure.java
  6. jenkins-infra-bot commented on Jan 15, 2013

    @jenkins-infra-bot
    Author
    jglick:

    JENKINS-9142 describes how to enable logging in bound objects.

  7. jenkins-infra-bot commented on Jan 15, 2013

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      The hard part is that there is no way to know when the page is being rendered when the bound object can be released: it may be used zero, one, or several times while the page is opened, at any time the user likes.

      Possible resolution: release the binding if no “ping” has been received from the rendered page for at least a minute; send a ping every fifteen seconds. Means creating some kind of Stapler adjunct and helper script and REST endpoint that lets the page send a short request to Jenkins periodically; Jenkins would keep a list of ping IDs and for each of these a list of bound objects.

    The hard part is that there is no way to know when the page is being rendered when the bound object can be released: it may be used zero, one, or several times while the page is opened, at any time the user likes.

    Possible resolution: release the binding if no “ping” has been received from the rendered page for at least a minute; send a ping every fifteen seconds. Means creating some kind of Stapler adjunct and helper script and REST endpoint that lets the page send a short request to Jenkins periodically; Jenkins would keep a list of ping IDs and for each of these a list of bound objects.

  8. jenkins-infra-bot commented on Jan 15, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java
    test/src/test/java/lib/layout/RenderOnDemandTest.java
    http://jenkins-ci.org/commit/jenkins/f178f0cef4bf86c5fb4cf4a2c40afce4c2b43410
    Log:
    JENKINS-16341 INSANE testing shows that a RenderOnDemandClosure binding adds about 380k, with or wothout 08efdf5.

  9. jenkins-infra-bot commented on Jan 15, 2013

    @jenkins-infra-bot
    Author
    dogfood:
    • Original comment link
    • Raw content of original comment:

      Integrated in jenkins_main_trunk #2193 JENKINS-16341 INSANE testing shows that a RenderOnDemandClosure binding adds about 380k, with or wothout 08efdf5. (Revision f178f0cef4bf86c5fb4cf4a2c40afce4c2b43410)

      Result = SUCCESS Jesse Glick : f178f0cef4bf86c5fb4cf4a2c40afce4c2b43410 Files :

      • test/src/test/java/lib/layout/RenderOnDemandTest.java
      • test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java

    Integrated in jenkins_main_trunk #2193
    JENKINS-16341 INSANE testing shows that a RenderOnDemandClosure binding adds about 380k, with or wothout 08efdf5. (Revision f178f0c)

    Result = SUCCESS
    Jesse Glick : f178f0cef4bf86c5fb4cf4a2c40afce4c2b43410
    Files :

    • test/src/test/java/lib/layout/RenderOnDemandTest.java
    • test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java
  10. jenkins-infra-bot commented on Jan 22, 2013

    @jenkins-infra-bot
    Author
    kohsuke:
    • Original comment link
    • Raw content of original comment:

      The other thing that helps is to make proxies have well-known URLs. If the fragment rendered on-demand do not depend on the request context (or if it can be recreated from future requests), then there won't be any need to keep session-scoped objects.

      Some of the core tags might very well fit with this, since they explicitly lists variables that get captured.

      But otherwise I agree that ping is the only way I can think of.

    The other thing that helps is to make proxies have well-known URLs. If the fragment rendered on-demand do not depend on the request context (or if it can be recreated from future requests), then there won't be any need to keep session-scoped objects.

    Some of the core tags might very well fit with this, since they explicitly lists variables that get captured.

    But otherwise I agree that ping is the only way I can think of.

  11. jenkins-infra-bot commented on Jan 22, 2013

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      RenderOnDemandClosure cannot be done this way AFAICT, since its variables are of unrestricted type. Nor can other uses of @JavaScriptMethod, unless we can somehow establish that the receiver object is a singleton.

    RenderOnDemandClosure cannot be done this way AFAICT, since its variables are of unrestricted type. Nor can other uses of @​JavaScriptMethod, unless we can somehow establish that the receiver object is a singleton.

  12. jenkins-infra-bot commented on Jan 22, 2013

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      @kohsuke points out that WithWellKnownURL may be used for singleton objects with a @JavaScriptMethod to avoid this bug. That is no help for <l:renderOnDemand>.

    @​kohsuke points out that WithWellKnownURL may be used for singleton objects with a @​JavaScriptMethod to avoid this bug. That is no help for .

  13. jenkins-infra-bot commented on Jan 22, 2013

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      Also users of ProgressiveRendering would be affected. Though this class implements its own ping-based timeout, returning "canceled" from news(), that does not also call Bound.release. The only fix for that, other than a general fix of this issue, would be to make ProgressiveRendering implement WithWellKnownURL, adding ongoing renders to a map keyed by random UUID and deleting them after sending back a cancel status.

    Also users of ProgressiveRendering would be affected. Though this class implements its own ping-based timeout, returning "canceled" from news(), that does not also call Bound.release. The only fix for that, other than a general fix of this issue, would be to make ProgressiveRendering implement WithWellKnownURL, adding ongoing renders to a map keyed by random UUID and deleting them after sending back a cancel status.

  14. jenkins-infra-bot commented on Jan 26, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:
    • Original comment link
    • Raw content of original comment:

      Code changed in jenkins User: Jesse Glick Path: changelog.html core/src/main/java/hudson/widgets/RenderOnDemandClosure.java http://jenkins-ci.org/commit/jenkins/47d6811666d5eb20bc491ea6ad4bda8f54f83be4 Log: JENKINS-16341 Amelioration of memory leak by at least interning some heavily redundant strings. (cherry picked from commit 08efdf5d3ab962cfd4c4c489266592fe1db7df8e)

      Conflicts: changelog.html core/src/main/java/hudson/widgets/RenderOnDemandClosure.java

    Code changed in jenkins
    User: Jesse Glick
    Path:
    changelog.html
    core/src/main/java/hudson/widgets/RenderOnDemandClosure.java
    http://jenkins-ci.org/commit/jenkins/47d6811666d5eb20bc491ea6ad4bda8f54f83be4
    Log:
    JENKINS-16341 Amelioration of memory leak by at least interning some heavily redundant strings.
    (cherry picked from commit 08efdf5)

    Conflicts:
    changelog.html
    core/src/main/java/hudson/widgets/RenderOnDemandClosure.java

  15. jenkins-infra-bot commented on Jan 26, 2013

    @jenkins-infra-bot
    Author
    scm_issue_link:
    • Original comment link
    • Raw content of original comment:

      Code changed in jenkins User: Jesse Glick Path: test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java test/src/test/java/lib/layout/RenderOnDemandTest.java http://jenkins-ci.org/commit/jenkins/5fe628076b6ee03f57bfa0767c6d0775aeafac1e Log: JENKINS-16341 INSANE testing shows that a RenderOnDemandClosure binding adds about 380k, with or wothout 08efdf5.(cherry picked from commit f178f0cef4bf86c5fb4cf4a2c40afce4c2b43410)

      Conflicts: test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java test/src/test/java/lib/layout/RenderOnDemandTest.java

    Code changed in jenkins
    User: Jesse Glick
    Path:
    test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java
    test/src/test/java/lib/layout/RenderOnDemandTest.java
    http://jenkins-ci.org/commit/jenkins/5fe628076b6ee03f57bfa0767c6d0775aeafac1e
    Log:
    JENKINS-16341 INSANE testing shows that a RenderOnDemandClosure binding adds about 380k, with or wothout 08efdf5.(cherry picked from commit f178f0c)

    Conflicts:
    test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java
    test/src/test/java/lib/layout/RenderOnDemandTest.java

  16. jenkins-infra-bot commented on Oct 9, 2014

    @jenkins-infra-bot
    Author
    jglick:
    • Original comment link
    • Raw content of original comment:

      There is BoundObjectTable.releaseMe but it does not seem to be called by anything. Nor does its implementation make sense: you would expect it to be static and actually use the BoundObjectTable instance found in the Ancestor.

    There is BoundObjectTable.releaseMe but it does not seem to be called by anything. Nor does its implementation make sense: you would expect it to be static and actually use the BoundObjectTable instance found in the Ancestor.

  17. jenkins-infra-bot commented on Jan 15, 2016

    @jenkins-infra-bot
    Author
    scm_issue_link:

    Code changed in jenkins
    User: Jesse Glick
    Path:
    test/src/main/java/org/jvnet/hudson/test/MemoryAssert.java
    http://jenkins-ci.org/commit/jenkins-test-harness/5eaf5f7459cf0bda87d9023f4c3f6080a073cbf6
    Log:
    JENKINS-16341 INSANE testing shows that a RenderOnDemandClosure binding adds about 380k, with or wothout 08efdf5.
    Originally-Committed-As: f178f0c

  18. jenkins-infra-bot commented on May 6, 2025

    @jenkins-infra-bot
    Author
    jglick:

    Partial fix in #10623 (comment) but still need to implement a timeout to solve the general case.

  19. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original depends_on from Jira: JENKINS-25081]

  20. removed
    bugFor changelog: Minor bug. Will be listed after features
    on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions