As reported in this issue https://github.com/AIDASoft/DD4hep/issues/1285 under certain circumstances the memory usage of DDG4 goes through the roof. This was traced back to the creation of excessive maps in the Geant4VolumeManager, if the number of sensitive pathes is very high like e.g. for straw detectors.
To solve the problem, geometry constructors may not declare any sensitive volumes. Hence the Geant4VolumeManager will not be populated. To still make Geant4 functioning, the sensitive volumes may be declared a posterior after conversion using regular expressions as implemented in the class Geant4RegexSensitivesConstruction. This class is only an example how such functionality may be achieved: other solutions are possible as well. This functionality can be switched at the level of each subdetector participating in the experiment setup.
To illustrate, an example detector BoxOfStraws was constructed with a flag in the xml description:
Change <non_sensitive/> to <sensitive/> and the different behavor of memory allocation when starting Geant4 can be observed.
The corresponding Geant4 python script can be found here:
BEGINRELEASENOTES
Geant4VolumeManager
, if the number of sensitive pathes is very high like e.g. for straw detectors.Geant4VolumeManager
will not be populated. To still make Geant4 functioning, the sensitive volumes may be declared a posterior after conversion using regular expressions as implemented in the classGeant4RegexSensitivesConstruction
. This class is only an example how such functionality may be achieved: other solutions are possible as well. This functionality can be switched at the level of each subdetector participating in the experiment setup.BoxOfStraws
was constructed with a flag in the xml description:Change
<non_sensitive/>
to<sensitive/>
and the different behavor of memory allocation when starting Geant4 can be observed. The corresponding Geant4 python script can be found here:The memory consumption differs then as follows (depending on the thickness of the straws, which determine the number of sensitive pathes):
With Sensitives matching regex and not sensitive volumes declared: before Geant4VolumeManager: Virtual: 903.3m Resident: 690.6m after Geant4VolumeManager: Virtual: 903.3m Resident: 690.6m Simulating: Virtual: 903.5m Resident: 692.6m