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


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

Re: deep copy or shallow copy?

From Lynn McGuire <lmc@winsim.com>
Newsgroups comp.lang.c++
Subject Re: deep copy or shallow copy?
Date 2014-08-07 12:29 -0500
Organization A noiseless patient Spider
Message-ID <ls0d2s$4lu$1@dont-email.me> (permalink)
References (2 earlier) <1isBv.124594$46.37874@fx19.iad> <lr689k$qos$1@dont-email.me> <lrn7ah$vsh$1@adenine.netfront.net> <lrr1fs$ehg$1@dont-email.me> <lrvmda$30qf$1@adenine.netfront.net>

Show all headers | View raw


On 8/7/2014 6:03 AM, Juha Nieminen wrote:
> Lynn McGuire <lmc@winsim.com> wrote:
>>> So your solution is to leak them? Yeah, because *that* makes sense
>>> with huge objects.
>>
>> How in the world did you get that from my answer?
>
> A comment in your first post didn't give much confidence in memory leaks
> being of the utmost priority: "We have very little memory leakage in
> our app". That makes it sound like "well, if something leaks, then it
> leaks; as long as it's efficient..."
>
> In well-designed C++ you almost never put raw pointers in a data
> container, unless that container is very, very tightly encapsulated
> into a class (that takes all the necessary steps to make sure that
> the managed objects are handled appropriately; in other words, it
> kind of acts like a "collective smart pointer" for all the objects
> pointed to by the elements of the vector.)
>
> Carelessly using vectors of pointers anywhere is just asking for
> trouble. If you really need pointers in the vector rather than
> objects by value, better to use smart pointers. (With C++11 this
> has become a lot more efficient with std::unique_ptr.)

Yes.  The key word here is carelessly.  We have master
containers of all allocated objects so making sure
that they all get freed at the correct time is fairly
easy for us.  Besides that, most of our datasets are
less than 1 MB in total size.  It is just the very
occasional 1+ GB dataset that gives me heartburn.

"well-designed"?  Is any long term commercial software
well designed?  We converted from Smalltalk to C++ over
a decade ago since our Smalltalk compiler / interpreter
was Win16 and the vendor died in 1995 or so.  Our
software has been available in the marketplace since
1969 and our Windows user interface has been available
since 1991.

I am stuck back at Visual Studio 2005 so I suspect
that we will not see std::unique_ptr very soon.  Maybe
in a decade or so.  We are more concerned with moving
our Fortran code to C++ than updating our C++ compiler.

Thanks,
Lynn

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


Thread

deep copy or shallow copy? mbalover2014@gmail.com - 2014-06-24 10:53 -0700
  Re: deep copy or shallow copy? Robert Wessel <robertwessel2@yahoo.com> - 2014-06-24 13:01 -0500
  Re: deep copy or shallow copy? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-06-24 20:19 +0000
    Re: deep copy or shallow copy? drew@furrfu.invalid (Drew Lawson) - 2014-06-26 12:43 +0000
      Re: deep copy or shallow copy? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-07-01 15:23 +0000
  Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-06-24 16:32 -0400
  Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-06-26 04:48 +0000
    Re: deep copy or shallow copy? JiiPee <no@notvalid.com> - 2014-07-18 10:37 +0100
    Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-22 13:28 -0700
      Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-22 16:37 -0400
        Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-23 03:17 -0700
          Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-23 08:47 -0400
            Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-23 14:14 -0700
      Re: deep copy or shallow copy? Wouter van Ooijen <wouter@voti.nl> - 2014-07-23 09:28 +0200
      Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-07-24 05:21 +0000
        Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-25 08:05 -0700
  Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-25 17:53 -0500
    Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-25 19:06 -0400
      Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-25 18:59 -0700
        Re: deep copy or shallow copy? ojackson520@gmail.com - 2014-07-25 23:56 -0700
        Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 13:35 +0000
          Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-28 15:54 -0500
            Re: deep copy or shallow copy? David Brown <david.brown@hesbynett.no> - 2014-07-29 12:30 +0200
              Re: deep copy or shallow copy? Reinhardt Behm <rbehm@hushmail.com> - 2014-07-29 18:56 +0800
              Re: deep copy or shallow copy? Tobias Müller <troplin@bluewin.ch> - 2014-07-29 12:03 +0000
              Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-29 14:21 +0000
                Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-29 12:39 -0400
                Re: deep copy or shallow copy? Martijn Lievaart <m@rtij.nl.invlalid> - 2014-07-29 18:48 +0200
                Re: deep copy or shallow copy? Wouter van Ooijen <wouter@voti.nl> - 2014-07-29 19:16 +0200
                Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-29 14:38 -0400
                Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-29 19:24 +0000
                Re: deep copy or shallow copy? David Brown <david.brown@hesbynett.no> - 2014-07-30 11:08 +0200
              Re: deep copy or shallow copy? Paavo Helde <myfirstname@osa.pri.ee> - 2014-07-29 15:30 -0500
      Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-26 01:37 -0500
        Re: deep copy or shallow copy? Ian Collins <ian-news@hotmail.com> - 2014-07-26 20:22 +1200
          Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-26 03:19 -0700
            Re: deep copy or shallow copy? Wouter van Ooijen <wouter@voti.nl> - 2014-07-26 14:34 +0200
          Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-26 16:56 -0500
            Re: deep copy or shallow copy? Richard Damon <Richard@Damon-Family.org> - 2014-07-26 18:26 -0400
            Re: deep copy or shallow copy? Ian Collins <ian-news@hotmail.com> - 2014-07-27 11:14 +1200
            Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-27 10:54 -0400
              Re: deep copy or shallow copy? "Osmium" <r124c4u102@comcast.net> - 2014-07-27 10:01 -0500
                Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-07-27 16:12 -0700
              Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-27 14:35 -0400
              Re: deep copy or shallow copy? Stuart <DerTopper@web.de> - 2014-07-28 17:24 +0200
                Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-28 12:52 -0400
                Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 18:43 +0000
            Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 13:39 +0000
        Re: deep copy or shallow copy? Victor Bazarov <v.bazarov@comcast.invalid> - 2014-07-26 11:34 -0400
          Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-26 16:59 -0500
    Re: deep copy or shallow copy? scott@slp53.sl.home (Scott Lurndal) - 2014-07-28 13:32 +0000
      Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-07-28 14:28 -0500
        Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-08-04 05:56 +0000
          Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-05 11:41 -0500
            Re: deep copy or shallow copy? Juha Nieminen <nospam@thanks.invalid> - 2014-08-07 11:03 +0000
              Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-07 12:29 -0500
        Re: deep copy or shallow copy? Öö Tiib <ootiib@hot.ee> - 2014-08-04 05:02 -0700
          Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-05 11:43 -0500
            Re: deep copy or shallow copy? Öö Tiib <ootiib@hot.ee> - 2014-08-05 17:13 -0700
              Re: deep copy or shallow copy? Lynn McGuire <lmc@winsim.com> - 2014-08-06 15:14 -0500
          Re: deep copy or shallow copy? CHIN Dihedral <dihedral88888@gmail.com> - 2014-08-20 20:56 -0700
  Re: deep copy or shallow copy? Mikołaj Małecki <ethouris@gmail.com> - 2014-08-11 00:13 -0700

csiph-web