Hello Experts!
I reading a book called programming with design pattern revealed
by Tomasz Muldner and here I read something that I don't understand
completely.
It says
"A garbarage collector, such as the one used in Java, maintains a record of
whether or not
an object is currentlys being used. An unused object is tagged as garbage,
which means
that it can be collected and returned to the pool of available memory. One
simple
technique used to implement a garbage collector is called reference
counting: Multiple objects share a single representation that keeps track of
the number of objects currently in use.
Reference counting is useful in everyday programming; for example, you
can use a string class, in which multiple objects can share the same
representation."
Now to my first question what does it mean with this sentence "Multiple
objects share a single representation that keeps track of the number of
objects currently in use."
Does it mean that many object share another object called X and in this
another object X is a reference counter that count the number of object
reference this object X.
Now to my second question what does it mean with this sentence "you
can use a string class, in which multiple objects can share the same
representation". This second question is the last part of sentence
"Reference counting is useful in everyday programming; for example, you
can use a string class, in which multiple objects can share the same
representation."
Many thanks
//Tony