开发者

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

开发者 https://www.devze.com 2023-04-07 07:35 出处:网络
There is an annotation or a开发者_如何学C keyword in Java that tells the garbage collector to remove some objects first when the memory is running out.

There is an annotation or a开发者_如何学C 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号