Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > pl.comp.programming > #30219

Re: Automatic Reference Counting

Path csiph.com!goblin3!goblin2!goblin.stu.neva.ru!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From Borneq <borneq@antyspam.hidden.pl>
Newsgroups pl.comp.programming
Subject Re: Automatic Reference Counting
Date Mon, 14 Aug 2017 15:10:41 +0200
Organization ATMAN - ATM S.A.
Lines 53
Message-ID <oms7gf$bbk$1@node2.news.atman.pl> (permalink)
References <omqmm6$vvs$1@node2.news.atman.pl> <7b945bb8-ec23-4680-a169-c90e9ec88592@googlegroups.com> <omqrh3$4kl$1@node2.news.atman.pl> <ec9d87ec-3839-4501-87ec-dbb68f38e59d@googlegroups.com> <omrm61$r61$1@node2.news.atman.pl> <bce4f6de-5a98-42a7-afd9-ff1b6ee42c37@googlegroups.com>
NNTP-Posting-Host 91.239.205.105
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace node2.news.atman.pl 1502716239 11636 91.239.205.105 (14 Aug 2017 13:10:39 GMT)
X-Complaints-To usenet@atman.pl
NNTP-Posting-Date Mon, 14 Aug 2017 13:10:39 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
In-Reply-To <bce4f6de-5a98-42a7-afd9-ff1b6ee42c37@googlegroups.com>
Content-Language pl
Xref csiph.com pl.comp.programming:30219

Show key headers only | View raw


W dniu 14.08.2017 o 10:31, M.M. pisze:
> Widzę że coś jak QMutexLocekr w Qt, tylko że mutex locker samo
> odblokowuje mutex a nie zwalnia pamięć :)
> http://doc.qt.io/qt-4.8/qmutexlocker.html

W poniższym przykładzie listy cyklicznej jest coś źle.
Shared nie powinien zwalniać, a zwalnia wszystkie z wyjątkiem jednego i 
to przed opuszczeniem test(),
zamiana na weak skutkuje tym że jest na zmianę tworzenie i zaraz 
zwalnianie. Coś nie tak, jak w teorii.

#include <memory>
#include <iostream>
using namespace std;

class Node
{
private:
	int n;
public:
	Node(int n): n(n)
	{
		cout << "Constructor Node is called " << n <<endl;
	}
	~Node()
	{
		cout << "Destructor Node is called " << n << endl;
	}
	shared_ptr<Node>  prev;
};



int test()
{
	shared_ptr<Node> node = shared_ptr<Node>(new Node(0));
	shared_ptr<Node> first = node;
	for (int i = 1; i < 5; i++)
	{
		shared_ptr<Node> prev = node;
		node = shared_ptr<Node>(new Node(i));
		node->prev = prev;
	}
	node->prev = node;
	printf("====\n");
     return 0;
}

int main()
{
	test();
	return 0;
}

Back to pl.comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-14 01:17 +0200
  Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-13 16:35 -0700
    Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-14 02:40 +0200
      Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-14 01:03 -0700
        Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-14 10:14 +0200
          Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-14 01:31 -0700
            Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-14 15:10 +0200
              Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-14 15:17 +0200
              Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-14 15:26 +0200
              Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-14 06:36 -0700
          Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-16 22:17 +0200
            Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-16 14:31 -0700
              Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-17 09:01 -0700
                Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-18 08:01 +0200
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-18 00:20 -0700
              Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-18 07:50 +0200
                Re: Automatic Reference Counting bartekltg <bartekltg@gmail.com> - 2017-08-18 01:42 -0700
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-18 01:53 -0700
                Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-18 11:37 +0200
                Re: Automatic Reference Counting bartekltg <bartekltg@gmail.com> - 2017-08-18 03:07 -0700
                Re: Automatic Reference Counting bartekltg <bartekltg@gmail.com> - 2017-08-18 03:10 -0700
                Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-18 12:38 +0200
                Re: Automatic Reference Counting bartekltg <bartekltg@gmail.com> - 2017-08-18 06:02 -0700
                Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-19 21:51 +0200
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-19 14:02 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-19 14:17 -0700
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-19 17:46 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-20 00:46 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-20 01:14 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-20 01:26 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-20 01:42 -0700
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-20 03:30 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-20 04:01 -0700
                Re: Automatic Reference Counting fir <profesor.fir@gmail.com> - 2017-08-20 04:16 -0700
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-20 04:51 -0700
                Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-20 10:41 +0200
                Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-20 10:35 +0200
                Re: Automatic Reference Counting Tomasz Kaczanowski <kaczus@poczta.onet.pl> - 2017-08-21 07:49 +0200
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-21 03:23 -0700
                Re: Automatic Reference Counting bartekltg <bartekltg@gmail.com> - 2017-08-20 04:55 -0700
                Re: Automatic Reference Counting "M.M." <mmarszik@gmail.com> - 2017-08-18 03:40 -0700
            Re: Automatic Reference Counting Wojciech Muła <wojtek.mula@gmail.com> - 2017-08-17 14:56 -0700
              Re: Automatic Reference Counting Borneq <borneq@antyspam.hidden.pl> - 2017-08-18 07:09 +0200
                Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-18 07:58 +0200
                Re: Automatic Reference Counting bartekltg <bartekltg@gmail.com> - 2017-08-18 01:50 -0700
              Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-18 07:54 +0200
        Re: Automatic Reference Counting "AK" <nobody@nowhere.net> - 2017-08-16 22:16 +0200

csiph-web