Message: New and delete operations in detector construction examples Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None New and delete operations in detector construction examples 

Forum: Documentation and Examples
Date: 10 Mar, 2005
From: Ben Morgan <Ben Morgan>

Hi,
   In all the detector construction example codes, many objects (e.g. G4Material, G4LogicalVolume, G4Box etc) are created with the 'new' operator but never -visibly-
deleted with 'delete'. I assume that this deletion is handled internally by G4, but it would be useful to know who (the user or G4) is responsible for the deletion of
certain objects (just call me paranoid about memory leaks :) ). This is not really apparent from the documentation or browsing the source code.

For instance, I'm adapting the BrachyMaterial class in the advanced brachytherapy example for my own application. This has many G4Element and G4Material objects created
with new, but not deleted at the end of a function or in in the destructor. In my material class some of the materials may not get added to logical volumes for certain geometry
configurations. Will this cause a memory leak or will G4 take care of the memory management?

I'd be most grateful for any advice or information on this! Thanks,

Ben Morgan.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: New and delete operations in detector construction examples   (Jeremy McCormick - 10 Mar, 2005)
 Add Message Add Message
to: "New and delete operations in detector construction examples"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]