In fact, the listener does not create a memory leak. However, they are often used improperly and can lead to leaks. Sometimes you see code in which an object refers to a component (for example, to display messages there), which has a listener that references (possibly indirectly) to the first object. This forms a cycle, and all its members live and die together. When a component is a dialogue that should be short-lived, you may have a problem. Beginners tend to use objects like
class MyKitchenSink implements Runnable, KeyListener, ....
which can have many links and simplifies the collection of memory leak * . Not creating "universal classes" is the way to go.
* "" , C, , . , , , .