从内存中移除数组。

huangapple 未分类评论58阅读模式
英文:

Removing array from memory in Java

问题

我试图在使用完一个二维数组后使其占用0内存。我想要实现类似这样的效果:

int a[][] = new int[10][10] // 分配新内存,假设为400Mb

// 进行一些操作

// 现在我想要将其置为null

a = null // 清除之前占用的400Mb内存

// 进行一些操作
英文:

I am trying to make a 2d array consume 0 memory after I am done using it.
I want to implement something likes this:-

int a[][] = new int[10][10] // alloting new memory say 400Mb

// do something

// Now I want to make it null

a => null // clearing the 400 Mb it took before

// do something

huangapple
  • 本文由 发表于 2020年3月16日 00:40:44
  • 转载请务必保留本文链接:https://java.coder-hub.com/60695219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定