# Garbage collection
English
In C++ language, it is the programmer's responsibility to de-allocate the memory allocated dynamically, keywords "new" and "delete" are used to allocate and reclaim memory. Programmers know about the importance of initialization, but often forget the importance of clearing up and leaving some memory unreclaimed.
TIP
在 C++ 语言中,释放动态分配的内存是程序员的责任,使用关键字“new”和“delete”来分配和回收内存。程序员知道初始化的重要性,但常常忘记清理和保留一些未回收的内存的重要性。
English
Java provides a garbage collectorto reclaim the memory of objects that are no longer used. The grabage colletor knows how to release memory allocated with "new". So you never to destroy an object! The memory de-allocation is automatically done. This mechanism is called "Gargage collection".
TIP
Java 提供了一个垃圾收集器来回收不再使用的对象所占用的内存。垃圾收集器知道如何释放通过 new 分配的内存。所以你永远不需要销毁一个对象!内存的释放是自动完成的。这种机制被称为“垃圾收集”。
English
Setting a reference to null meands it is no longer referning to any object. An object which is not referred by any reference will be removed from memory by the garbage collector. All object are living on the heap.
TIP
将引用设置为 null 意味着它不再引用任何对象。未被任何引用的对象将被垃圾收集器从内存中移除。所有对象都存在于堆中。