素材牛VIP会员
Can using too many static variables cause a memory leak in Java?
 qi***hu  分类:Java代码  人气:619  回帖:1  发布于6年前 收藏

If my application has too many static variables or methods, then as per definition they will be stored in heap. Please correct me if I am wrong
1) Will these variables be on heap until application is closed?
2) Will they be available for GC at any time? If not can I say it is a memory leak?

 标签:java

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv1 新人
Al***ay 职业无 6年前#1

1) yes. if they are reference type, they will be stored in heap.
2) no, but if their classloaders are collected, may be they are. memory leak? that depends on you.

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取