Linked Questions

30 votes
3 answers
5k views

I have been trying to understand the difference between different references but the theory does not provoke any ideas for me to visualize the same. Could anyone please explain in brief the different ...
Jegan Kunniya's user avatar
597 votes
33 answers
2.5m views

I am writing a client-side Swing application (graphical font designer) on Java 5. Recently, I am running into java.lang.OutOfMemoryError: Java heap space error because I am not being conservative on ...
Eugene Yokota's user avatar
172 votes
10 answers
63k views

The use of weak references is something that I've never seen an implementation of so I'm trying to figure out what the use case for them is and how the implementation would work. When have you needed ...
18Rabbit's user avatar
  • 3,231
193 votes
4 answers
110k views

I have been a Java developer for 2 years. But I have never written a WeakReference in my code. How to use WeakReference to make my application more efficient, especially the Android application?
Chris's user avatar
  • 6,661
87 votes
5 answers
54k views

It's easy to write extension methods in Kotlin: class A { } class B { fun A.newFunction() { ... } } But is there some way to create extension variable? Like: class B { var A.someCounter: Int ...
Letfar's user avatar
  • 3,563
21 votes
10 answers
18k views

I have a cache which has soft references to the cached objects. I am trying to write a functional test for behavior of classes which use the cache specifically for what happens when the cached objects ...
John Goering's user avatar
  • 39.2k
8 votes
14 answers
1k views

I approached it similar to the case of deleting any usual object, ie, simply making the reference null and letting the Garbage Collector do its job. However for equating to null within a class, the ...
Saurabh Agarwal's user avatar
11 votes
5 answers
8k views

is there an elegant way in Java to set all existing object-pointers to null? I want an object to be deleted, but it is registered in several places an Event Listener.
Skip's user avatar
  • 6,591
21 votes
7 answers
5k views

I am currently trying to diagnose a slow memory leak in my application. The facts I have so far are as follows. I have a heap dump from a 4 day run of the application. This heap dump contains ~800 ...
mchr's user avatar
  • 6,282
8 votes
4 answers
6k views

I read many articles, but I don't understand - where do I need to use Weak and Phantom references in practice? Soft references - is a good choice for cache, as I understand. But weak and phantom, I ...
VladislavLysov's user avatar
1 vote
3 answers
4k views

How can i delete object even it has references(c# or Java)? For example: void Main() { var f = new Foo(); var person = f.GetPerson(); } public class Foo { private object _person; ...
Neir0's user avatar
  • 13.5k
8 votes
2 answers
1k views

Per the documentation for Guava's MapMaker.softValues(): Warning: in most circumstances it is better to set a per-cache maximum size instead of using soft references. You should only use this method ...
Paul Bellora's user avatar
  • 55.4k
3 votes
2 answers
1k views

I am trying to study the meaning of a soft reference via this 'Soft References in Java' article: https://www.baeldung.com/java-soft-references My problem in understanding this article is that it ...
Very Objective's user avatar
4 votes
2 answers
2k views

I am trying to use WeakHashMap as a concurrent Set of weak references. this.subscribers = Collections.synchronizedSet( Collections.newSetFromMap( ...
Basil Bourque's user avatar
1 vote
2 answers
628 views

Let's say I have an object called "master" which owns 100 objects called "slave0" through "slave99" respectively. (This is not an array. I have 100 fields in my "master" class called salve0 to slave99 ...
Jonathan Sylvester's user avatar

15 30 50 per page