Tag

Anonymous Inner Class

1 views collected around this technical thread.

Selected Java Interview Questions
Selected Java Interview Questions
Jan 5, 2024 · Backend Development

Do Lambda Expressions Cause Memory Leaks Like Anonymous Inner Classes in Java?

This article analyzes whether Java lambda expressions can lead to memory leaks similar to anonymous inner classes by comparing their compiled bytecode, demonstrating that lambdas only retain a reference to the outer class when they explicitly capture its members.

AndroidAnonymous Inner ClassJava
0 likes · 8 min read
Do Lambda Expressions Cause Memory Leaks Like Anonymous Inner Classes in Java?
Cognitive Technology Team
Cognitive Technology Team
Sep 12, 2022 · Fundamentals

Avoiding Memory Leaks with Java Double‑Brace Initialization and Anonymous Inner Classes

This article explains Java's double‑brace initialization trick, shows how it creates anonymous inner classes, demonstrates the resulting memory‑leak and OOM risks, especially with non‑static inner classes, and provides guidelines such as using static inner classes or weak references to avoid these problems.

Anonymous Inner ClassDouble Brace InitializationJava
0 likes · 7 min read
Avoiding Memory Leaks with Java Double‑Brace Initialization and Anonymous Inner Classes
Selected Java Interview Questions
Selected Java Interview Questions
Sep 29, 2020 · Backend Development

Why Java Anonymous Inner Classes Require Final or Effectively Final Variables and How Kotlin Handles Them Differently

The article explains why Java anonymous inner classes can only access final or effectively final variables, shows the compiler‑generated bytecode that enforces this rule, and contrasts it with Kotlin's approach of wrapping primitives to allow modification inside such classes.

Anonymous Inner ClassCompilationEffective Final
0 likes · 6 min read
Why Java Anonymous Inner Classes Require Final or Effectively Final Variables and How Kotlin Handles Them Differently