使用太多的静态变量会引起java内存泄漏? -问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

使用太多的静态变量会引起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 3569 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
    赞同 展开评论 打赏
问答分类:
相关产品:
问答排行榜
最热
最新
相关课程
更多
相关电子书
更多
JAVA开发手册1.5.0
立即下载
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
相关实验场景
更多