Neo Tran

Hi there, sharing is one of my favorite activities since I believe it’s an important part of building our world today. Get connected and enjoy something new !

Read this first

References in OOP

banner_references.jpg

1. What is a reference

Reference, a concept of OOP language, is a variable contains a value of the address which refers (or points) to where in memory an object is stored.
Reference.jpg
To make it easier to understand, let me give an example: Your house is somewhere in the city, and a friend cannot know it until you give him a visit card which contains the house’s address. In this case, the card is a reference and the house is an actual space or value in memory.

However, be careful with the another concept, Pointer in C++ programming. Actually, reference and pointer seem to do some same or similar things. Especially, we can use them for accessing an object.
MemoryAddressContent.png
Pointer, on the other hand, is different from reference in some cases. If you are interested in C++ programming, please check more here

2. Where is a reference?

References are stored in a Stack and the objects which they refer to are...

Continue reading →


What is a Garbage Collector?

recycling-waste-garbage-portrait-municipal-worker-collector-truck-loading-trash-bin-34396471.jpg

1. What is it

  • A garbage collector (GC), a concept of computer science, simply is a program or process which is run by OS, in order to free some space of the device’s memory which was allocated before and now is not used anymore. In other words, we can say that it is a form of memory management.
  • As the previous post, we read about References in OOP and know about a process of cleaning memory. So in some operating systems, GC takes care of that process.
  • Let’s move to the next part to see how garbage collector works.

2. How does garbage collector work?

  • Because of the name “Garbage Collector”, many of us usually think that GC finds, collects and cleans all unused objects. On the contrary, GC does the opposite, it finds and marks all live objects which are being used, and then everything else will be cleared away.
  • So how does GC know which objects are used or not? GC checks the...

Continue reading →