Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

WeakCache

Guides

  • Weak Cache Functions

Symbols

  • CheckWeakCache
  • CleanupAfter
  • ClearHistory
  • ClearWeakCache
  • CreateReference
  • SameInstanceQ
  • SetWeakCache
  • StrongReference
  • WeakHashTable
  • WeakReference
JasonB`WeakCache`
WeakReference
​
WeakReference
[..]
represents a reference to an expression which does not ensure the expression is kept in memory for the lifetime of the reference.
​
​
WeakReference
[..][]
returns the referenced expression.
​
Details and Options

Examples  
(1)
Basic Examples  
(1)
Create an object during and return a weak reference to it:
In[1]:=
$HistoryLength=0;
In[2]:=
obj=RandomGraph[{10,15}];​​
CleanupAfter
[obj,Echo["deleting obj now"]];​​ref=
CreateReference
[obj,"Weak"]
Out[2]=
<WeakReference>
CleanupAfter
is used above to demonstrate when the underlying object is deleted from memory. Clearing the variable obj will delete all references to the data:
In[3]:=
obj=.
»
deleting obj now
You can no longer retrieve the stored object using the weak reference:
In[4]:=
ref[]
Out[4]=
Failure

Message:
The reference has expired.
Tag:
ExpiredReference

SeeAlso
CreateReference
 
▪
StrongReference
RelatedGuides
▪
Weak Cache Functions
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com