Problem 364 - Memory full when using G4RotationMatrix in G4PVParameterised
Summary: Memory full when using G4RotationMatrix in G4PVParameterised
Status: RESOLVED INVALID
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry/management (show other problems)
Version: 4.0
Hardware: PC All
: P2 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2002-03-18 03:06 CET by swald
Modified: 2002-04-22 04:24 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description swald 2002-03-18 03:06:27 CET
I use G4RotationMatrix to parameterise a segmented Tube(in phi-angle) with
G4PVParameterised (like example2). I used this Tube as ReadOutGeometry . During
running some events G4RotationMatrix was always builded new but it was not
destroyed until I leave geant4 . Througth this more and more memory is used
during running geant4 until the memory is full and the simulation doesn't goes
on.
Comment 1 Gabriele Cosmo 2002-03-28 02:58:59 CET
Problem under investigation.
Comment 2 Gabriele Cosmo 2002-03-28 04:13:59 CET
The problem can only be in the user code.
According to the complexity of the geometry, dynamic allocation of objects
must be carefully considered and managed. It looks like that in this case the
required parameterisation implemented by the user is the responsible of the
problem. Rotation matrices or generic transformations are not allocated by
the Geant4 kernel in the event loop.
Comment 3 swald 2002-04-03 02:25:59 CEST
The problem is that the NameSD.cc file of the ReadOutGeometry asks for the
Rotation ,from the ComputeTransformation method of the parateterisation ,with
  G4RotationMatrix rotM;
  rotM=*(physVol->GetObjectRotation());
  NameHit->SetRot(rotMat);
which was set in ComputeTransformation in the parameterisation through
  G4RotationMatrix* RotMat=new G4RotationMatrix(angle,0,0);
  physVol->SetRotation(Rotmat);

How could the rotation used in this files without using more and more memory?
Comment 4 Gabriele Cosmo 2002-04-17 04:10:59 CEST
The lifetime of transformations for parameterisations is the same as for the
instance of the G4VParameterisation user class. The problem could be solved by
simply making the rotation matrix an attribute of the user parameterisation
and allocating it in its constructor (then deleted in the destructor), instead
of doing this inside the ComputeTransformation() method. Hope it helps.
Comment 5 swald 2002-04-18 10:31:59 CEST
I have placed the G4RotationMatrix in the parameterisation file in the
constructor ,but it always consumes more and more memory when the program is
running.
Can you send me programlines which doesn't consume more and more memory for my
problem ?
Comment 6 Gabriele Cosmo 2002-04-22 04:24:59 CEST
Hi, I think you have all the elements to correctly implement the
parameterisation you need. This is C++ programming... sorry.
You must remove the 'new' statement from your ComputeTransformation()
and replace it with the required calls to modifiers for the rotation
matrix (see specification of the HepRotation class in CLHEP/Vector/Rotation.h)
you defined in your parameterisation class.
If the application still leaks memory after this (i.e. no 'new' statements
are included in ComputeTransformation()), the cause might then be elsewhere.