Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clarifying weak caching vs manual management#3820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
joaquinelio wants to merge2 commits intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromjoaquinelio:patch-20
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -469,6 +469,9 @@ Of course, it is important to remember, that such behavior is not guaranteed, an
Based on this, a completely logical question immediately arises: why do not we use an ordinary cache, where we can manage its entities ourselves, instead of relying on the garbage collector?
That's right, in the vast majority of cases there is no need to use `WeakRef` and `FinalizationRegistry`.

We use this approach when we suspect, as in this case, that memory management might be an issue, allowing for a more flexible and adaptable implementation.
We don’t always manage manually because we no longer program for fixed hardware; we delegate to the engine, which adjusts behavior based on available resources.

Here, we simply demonstrated an alternative implementation of similar functionality, using a non-trivial approach with interesting language features.
Still, we cannot rely on this example, if we need a constant and predictable result.

Expand All@@ -480,4 +483,4 @@ You can [open this example in the sandbox](sandbox:weakref-finalizationregistry)
This is beneficial for addressing excessive memory usage and optimizing the utilization of system resources in applications.

`FinalizationRegistry` - is a tool for registering callbacks, that are executed when objects that are no longer strongly referenced, are destroyed.
This allows releasing resources associated with the object or performing other necessary operations before deleting the object from memory.
This allows releasing resources associated with the object or performing other necessary operations before deleting the object from memory.

[8]ページ先頭

©2009-2025 Movatter.jp