Skip to Content.
Sympa Menu

charm - Re: [charm] destructor for variable-size messages

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

Re: [charm] destructor for variable-size messages


Chronological Thread 
  • From: Phil Miller <mille121 AT illinois.edu>
  • To: Nicolas Bock <nicolasbock AT gmail.com>
  • Cc: "charm AT cs.uiuc.edu" <charm AT cs.uiuc.edu>
  • Subject: Re: [charm] destructor for variable-size messages
  • Date: Wed, 13 Nov 2013 15:03:57 -0800
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm/>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>

No, you don't need to define a destructor. Particularly, defining a destructor that deletes runtime-allocated arrays within a message would cause the program to blow up.

When you declare a message class FooMsg in a .ci file, you name some variable-length arrays bar, baz, and qux that are part of it. The generated code for operator new allocates this message class and all of the variable-length arrays declared as part of it in one unit, and deallocates them the same way. So, calling delete on one of those arrays would be asking the memory allocator to release something that it never actually allocated.


On Wed, Nov 13, 2013 at 1:44 PM, Nicolas Bock <nicolasbock AT gmail.com> wrote:
Hi,

do I need to define a destructor for variable size messages? Taking
the examples in section 10.1.2, is it necessary to define something
like:

MyVarsizeMsg::~MyVarsizeMsg (void)
{
  delete[] arr1;
  delete[] arr2;
  delete arr3;
}

Thanks,

nick
_______________________________________________
charm mailing list
charm AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/charm




Archive powered by MHonArc 2.6.16.

Top of Page