While rare, memory leaks can still occur in Java, and ``++static++`` collections are a classic source. This is because ``++static++`` class variables hang around for the life of a program. Unless the contents are diligently managed, items added to the collection shortly after start up will still be there in the collection - and in memory - until shutdown. Thus, you should be very certain that ``++static++`` collections are both required and well-managed. 


This rule raises an issue on each ``++static++`` collection.


== Noncompliant Code Example

----
public class MyClass {
  private static Map <String, Thingy> lookup = new HashMap<>();  // Noncompliant
----


== Exceptions

This rule ignores ``++WeakHashMap++``s, because according to the JavaDocs:

____
An entry in a ``++WeakHashMap++`` will automatically be removed when its key is no longer in ordinary use. More precisely, the presence of a mapping for a given key will not prevent the key from being discarded by the garbage collector... When a key has been discarded its entry is effectively removed from the map...
____

However, it is important to note:

____
The value objects in a ``++WeakHashMap++`` are held by ordinary strong references. Thus care should be taken to ensure that value objects do not strongly refer to their own keys, either directly or indirectly, since that will prevent the keys from being discarded.
____

