Re: Psuedo-dynamic allocation?

From: Robbie Hatley (loneXwolfintj_at_pacXbell.net.remove-Xs-include-)
Date: 05/07/04


Date: Fri, 7 May 2004 01:31:05 -0700


"John Harrison" <john_andronicus@hotmail.com> wrote in message news:2g0s9iF33ql5U1@uni-berlin.de...

> (answers to my fears re. memory leaks)

Thanks for the clarification.

> ... Yes. But I'd quibble about your terminology. make_pair does not create
> anything dynamically, that would imply use of new, which make_pair does not
> use....

Ah, you mean "dynamically" in the sense of creating objects which still
exist after the code that created them goes out of scope:

void Dweevil (unsigned check)
{
   double * Qbert = new unsigned double;
   ... (hundreds of lines of code) ...
   return;
} // leave scope
// Oops! Forgot to delete Qbert ! Memory leak!

I meant "dynamic", however, in the sense of not specifying in advance
how many objects will be created or what their names will be.

This is the kind of thing I'd call "pseudo-dynamic":

struct Glurk
{
   char broil;
   long shot;
}
void Bard (double bubble)
{
   list<Glurk> Grendel;
   if (bubble > 19.7)
   {
      Grendel.push_back(Glurk()); // pseudo-dynamically create new Glurk
   }
   ... (hundreds of lines of code) ...
   return;
} // leave scope, free memory.

This can be a very useful concept, I'm beginning to see.

-- 
Cheers,
Robbie Hatley
Tustin, CA, USA
email: lonewolfintj at pacbell dot net
web: home dot pacbell dot net slant earnur slant
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


Relevant Pages

  • Re: Confusion about Image object and PictureBox usage.
    ... I am not sure if I have a memory leak or not. ... >> scope, as with almost all objects in .NET. ... >> leak is coming from elsewhere, possibly in the code that is converting ... >> JPEG getting converted to a .NET bitmap? ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Elbereth = Chaotic ?!
    ... > With a hey derry tum gardol ... > birds plopped heavily to the ground in front of Frito. ... home dot pacbell dot net slant earnur slant ...
    (rec.games.roguelike.nethack)
  • Re: Memory leak in ruby code
    ... Even when it's out of scope, ... leaks in ruby code is still not very clear to me. ... I'd like to see if someone can point me to an example of memory leak ... Dont judge those who try and fail, judge those who fail to try.. ...
    (comp.lang.ruby)
  • Re: survival of c++
    ... C and C++ have function types. ... Very good for file utilities ... home dot pacbell dot net slant earnur slant ...
    (comp.lang.cpp)
  • Re: pet shop lifting
    ... So if your pet doesn't seem to want to follow you ... reluctance to cross the threshold. ... home dot pacbell dot net slant earnur slant ...
    (rec.games.roguelike.nethack)