| Summary: | Memory full when using G4RotationMatrix in G4PVParameterised | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | swald |
| Component: | geometry/management | Assignee: | Gabriele Cosmo <Gabriele.Cosmo> |
| Status: | RESOLVED INVALID | ||
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 4.0 | ||
| Hardware: | PC | ||
| OS: | All | ||
|
Description
swald
2002-03-18 03:06:27 CET
Problem under investigation. 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. 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? 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. 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 ? 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. |