请在内存分配和垃圾回收之间有什么区别? [英] What's the difference between memory allocation and garbage collection, please?

查看:88
本文介绍了请在内存分配和垃圾回收之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解垃圾回收"是内存管理的一种形式,它是自动回收未使用的内存的一种方式.

I understand that 'Garbage Collection' is a form of memory management and that it's a way to automatically reclaim unused memory.

但是内存分配"和垃圾回收"的概念区别是什么?

But what is 'memory allocation' and the conceptual difference from 'Garbage Collection'?

推荐答案

它们是相反的事物.是的,差异很大.

They are Polar opposites. So yeah, pretty big difference.

分配内存是指声明用于存储事物的内存空间的过程.

Allocating memory is the process of claiming a memory space to store things.

垃圾回收(或释放内存)是将内存释放回可用内存池的过程.

Garbage Collection (or freeing of memory) is the process of releasing that memory back to the pool of available memory.

当变量被声明/初始化并且超出范围时,许多更新的语言会在后台为您执行这两个步骤.

Many newer languages perform both of these steps in the background for you when variables are declared/initialized, and fall out of scope.

这篇关于请在内存分配和垃圾回收之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆