# TIP: Use Weak References

DevFeed: [TIP: Use Weak References](<https://devfeed.tech/articles/tip-use-weak-references-19612.md>)

Original publisher: [Read original article](<https://www.codenameone.com/blog/tip-weak-references/>)

Author: Shai Almog

Published: 2017-10-16T00:00:00Z

Content type: tutorial

Language: en

Sources: [CodeName One](<https://devfeed.tech/sources/codename-one.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>), [Swift](<https://devfeed.tech/topics/swift.md>)

Tags: [gc](<https://devfeed.tech/tags/gc.md>), [java](<https://devfeed.tech/tags/java.md>), [memory](<https://devfeed.tech/tags/memory.md>), [object](<https://devfeed.tech/tags/object.md>)

## AI overview

This tutorial explains how weak references work in Java garbage-collected environments. It describes how they allow objects, such as memory-intensive images, to be reclaimed when needed, and discusses Codename One's weak-reference APIs and platform limitations.

## Source excerpt

One of the less familiar features of Java is the mess of weak/soft/phantom references. This is a confusing mess and it's compounded by the fact that other languages (such as the reference counting Swift/Objective-C) have used these terms with a different meaning. To simplify this weak references in a garbage collected language allows you to keep a pointer (reference) to an object that won't force it to stay in RAM.