ruby / ruby/json

Don't cache JRuby runtime in static fields

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

@headius is already working on this.

Since Nov 21, 2024.

jruby
Dominant language
Ruby
Stars
782
Forks
383
Avg merge
1d 18h
Merged PRs (30d)
10

Description

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.

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.