Don't cache JRuby runtime in static fields

Open
#707 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@headius is already working on this.

Since Nov 21, 2024.

Assessment

This issue has not been assessed yet.

Description

jruby

There are a few places where we cache the JRuby runtime or runtime-specific objects in a static field, such as here with a WeakReference:

https://github.com/ruby/json/blob/7d2ad6d6556da03300a5aeadeeacaec563435773/java/src/json/ext/RuntimeInfo.java#L83-L91

The runtimes cached in weak references will not "leak" but it may take longer for the runtime to be collected than normal. In addition, the cost of traversing the weak reference may offset any gains from caching runtime objects.

These should be removed and cached in a runtime-safe way.

Dominant language
Ruby
Stars
785
Forks
390
Avg merge
7h 14m
Merged PRs (30d)
15

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/json

All issues in ruby/json

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.