Skip to content

Memory leak from ActiveRecord_Relation after upgrading from JRuby 9.4.9.0 to 9.4.10.0 #8598

@skunkworker

Description

@skunkworker

Environment Information

Provide at least:
JRuby 9.4.10.0-jdk21

-J-Djava.security.egd=file:/dev/./urandom -J-XX:+UseG1GC -J-XX:+UseStringDeduplication -J-Xms2560m -J-Xmx4608m -J-server -Xcext.enabled=true --disable:did_you_mean

Docker image:jruby:9.4.10.0-jdk21

Other relevant info you may wish to add:
Rails 6.1, Rails 7.0

Expected Behavior

Under JRuby 9.4.9.0 the JVM heap would be very consistent (see graph). But under 9.4.10.0 we saw a massive increase in heap usage as well as garbage collection (GC) issues causing cpu spikes and leading to dropped requests.

Looking at a grabbed heap dump I noticed that 250mb of heap was used for a very large subclassNode -> next -> next -> next ... data structure.

Image

Thanks to @headius for this simple reproducible script.

loop { class << Object.new; end }

Actual Behavior

Below is the heap usage on an application and the only change is the JRuby version from 9.4.9.0 to 9.4.10.0
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions