Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotation or keyword to tell garbage collector of objects to remove first

There is an annotation or a keyword in Java that tells the garbage collector to remove some objects first when the memory is running out.

Unfortunately I've forgotten it's name. Do you know it?


2 Answers

I think I'm safe in saying that your memory's in error. You may be thinking of reference objects.

like image 93
Ed Staub Avatar answered Jan 01 '26 21:01

Ed Staub


I can't even see how you would annotate an object. Annotations are a compile time thing and objects are a runtime thing.

Perhaps you meant to say something like "how do I annotate a class to tell the garbage collector to collect objects of this class before any other objects".

I've never heard of such feature though.

Perhaps you're thinking of some cache eviction algorithms:

  • least recently used (LRU),
  • least frequently used (LFU), or
  • first in first out (FIFO)

In that case, have a look at the EHCache library.

like image 33
aioobe Avatar answered Jan 01 '26 22:01

aioobe