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


Groups > comp.lang.c++ > #5387

Re: Interpeting valgrind

From Ruben Safir <ruben@mrbrklyn.com>
Newsgroups comp.lang.c++
Subject Re: Interpeting valgrind
Date 2011-05-24 02:37 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <irf5kn$at1$1@reader1.panix.com> (permalink)
References (1 earlier) <cone.1306107376.32708.16159.500@monster.email-scan.com> <70a85274-88f9-4a18-b45c-50f05e91773c@l26g2000yqm.googlegroups.com> <cone.1306113809.229005.17178.500@monster.email-scan.com> <irek9g$dno$4@reader1.panix.com> <ireoit$iph$1@hoshi.visyn.net>

Show all headers | View raw


On Tue, 24 May 2011 00:54:17 +0200, Kai-Uwe Bux wrote:

> Ruben Safir wrote:
> 
> [...]
>> But look at this
>> ==26349== 121,600 (1,600 direct, 120,000 indirect) bytes in 100 blocks
>> are definitely lost in loss record 17 of 17 ==26349==    at 0x4027400:
>> operator new(unsigned int) (in
>> /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==26349==    by
>> 0x8048E49: creating_int_list() (test_del2.cpp:105) ==26349==    by
>> 0x8048A89: main (test_del2.cpp:55) ==26349==
>> 
>> 
>> 
>> Ok those lines are as follows - the call function designed to allocate
>> a list of integers and return them (in this case to main
>>       std::cout << "CREATING LIST for ARRAY
>>       -------------------------------\n"; a[i] = creating_int_list();
>> 
>> 
>> chainlist::List<int> * creating_int_list(){
>>    // chainlist::List<int>  set = new chainlist::List<int>;
>>    chainlist::List<int> * set = new chainlist::List<int>; int ran;
>>    for(int i = 0; i < 100; ++i){
>>       ran=rand();
>>       set->insert(ran % 100);
>>    }
>>    set->display();
>>    return set;
>> }
>> 
>> 
>> If I chose to delete the returned List pointed to by set, it have to be
>> done OUT of that function otherwise the function has no point
>> 
>> So upon complaint i did just that
>> 
>> 
>>    for( i=0; i < 100; ++i){
>>       delete a[i];
>>    }
>>    return EXIT_SUCCESS;
>> 
>> 
>> That had NO IMPACT on the report.
> [...]
> 
> Then, it looks as though the destructor of chainlist::List<int> is not
> releasing the resources properly. I looked upthread for that destructor.
> It relies upon a method remove_front() which you posted as:
> 
>    template<class T>
>       void List<T>::remove_front(){
> ////     std::cout << "Removing the Front " << front() << " End of List
> is "<< endd() << std::endl;
> 
>          if(front() == 0){
> //          std::cout << "Front  is NULL " << front() << std::endl;
>             return;
>          }
>          if(front() == endd()){
> //
> //          std::cout << "Front  is End " << front() << std::endl;
>             Node<T> * tmp = front();
>             delete tmp;
>             front(0);
>             endd(0);
>             cursor() = 0;
>             sizedown();
>             return;
>          }
> 
> The code looks incomplete, so I cannot comment on the correctness. But
> that is, where I would search.
> 
> 
> Best,
> 
> Kai-Uwe Bux

Thanks

I've followed that code very closely and did a shake out of it a month 
ago when I had a double delete.  It definitely walks through the entire 
list and does the deletions, and the nodes have their own destructors.

The pointers themselves can't be deleted and are automatic variable

Ruben

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Interpeting valgrind Ruben Safir <ruben@mrbrklyn.com> - 2011-05-22 23:03 +0000
  Re: Interpeting valgrind Sam <sam@email-scan.com> - 2011-05-22 18:36 -0500
    Re: Interpeting valgrind mrbrklyn <ceo.brooklyn@gmail.com> - 2011-05-22 17:23 -0700
      Re: Interpeting valgrind Sam <sam@email-scan.com> - 2011-05-22 20:23 -0500
        Re: Interpeting valgrind Ruben Safir <ruben@mrbrklyn.com> - 2011-05-23 21:41 +0000
          Re: Interpeting valgrind Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-24 00:54 +0200
            Re: Interpeting valgrind Ruben Safir <ruben@mrbrklyn.com> - 2011-05-24 02:37 +0000
              Re: Interpeting valgrind Michael Doubez <michael.doubez@free.fr> - 2011-05-24 01:36 -0700
                Re: Interpeting valgrind Ruben Safir <mrbrklyn@panix.com> - 2011-05-27 18:08 +0000
                Re: Interpeting valgrind Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-27 22:43 +0000
                Re: Interpeting valgrind Ruben Safir <ruben@mrbrklyn.com> - 2011-05-27 23:01 +0000
                Re: Interpeting valgrind Michael Doubez <michael.doubez@free.fr> - 2011-05-29 12:41 -0700
            Re: Interpeting valgrind Ruben Safir <ruben@mrbrklyn.com> - 2011-05-24 02:48 +0000

csiph-web