开发者社区> 问答> 正文

使用太多的静态变量会引起java内存泄漏?

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?

展开
收起
蛮大人123 2016-02-29 10:51:11 3706 0
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.

    2019-07-17 18:50:08
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载