Thanks, but can you please explain what is the purpose of above code?

I suppose you are getting the issue when using Delphi's ARC, right?