[Qt-interest] Qt memory management.

Ramesh ramesh.bs at robosoftin.com
Wed Aug 18 14:01:16 CEST 2010


Thanks Arnold :)
Have nice day.


-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Arnold Krille
Sent: Wednesday, August 18, 2010 5:03 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Qt memory management.

On Wednesday 18 August 2010 13:10:25 Ramesh wrote:
> Fine andres..
> I do agree.. but what about this case.
>
> QString a = "foo"; // "QStringPrivate" has a refcount of 1 QString b =
> a;// Shallow copy of QStringPrivate, that now has a refcount of
> 2
> a = "chock" // in this case?
>
> If we change the value of a, then what about b?
>
>  b should point to "foo" right. So what happens in this case, I guess
> Deepcopy occurs right?

"Copy on write" means that whatever reference gets its value changed, it
checks for the ref-counter and if that is bigger then 1, it creates its own
copy to modify.
So after >a= "chock";<, a has "chock" and b still has "foo", both with a
ref- counter of 1.

Arnold


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.



More information about the Qt-interest-old mailing list