OpenGATE / Gate

Official public repository of Gate
http://www.opengatecollaboration.org
GNU Lesser General Public License v3.0
232 stars 262 forks source link

Memory Leak issue in optical simulations #278

Open baiw71 opened 4 years ago

baiw71 commented 4 years ago

Hi all,

Recently, I noticed a serious leak in memory when running my simulations.I noticed that the memory leak is caused by attaching a phantomSD to the voxelized geometry and it will be far severe when more information is added to the voxelized image/source e.g. extending the material properties (material.xml file needed for optical simulations) or adding energy spectrum for the source.

I need to add that I am using Gate8.2 on ubuntu. Below you can find the macro to reproduce the issue.

 /vis/disable

/gate/geometry/setMaterialDatabase    GateMaterials.db /gate/world/geometry/setXLength       20 cm /gate/world/geometry/setYLength       20 cm /gate/world/geometry/setZLength       30 cm /gate/world/setMaterial                         Air /gate/world/vis/forceWireframe 1

/gate/world/daughters/name voxelizedPhantom /gate/world/daughters/insert ImageNestedParametrisedVolume /gate/voxelizedPhantom/geometry/setImage Macros/voxelizedPhantom.mhd /gate/voxelizedPhantom/geometry/setRangeToMaterialFile Macros/phantomMaterial.dat /gate/voxelizedPhantom/attachPhantomSD

/gate/actor/addActor FluenceActor MyActor /gate/actor/MyActor/save  actorOutput.mhd /gate/actor/MyActor/attachTo       voxelizedPhantom /gate/actor/MyActor/stepHitType    random /gate/actor/MyActor/setSize        5 5 5 cm /gate/actor/MyActor/setResolution     128 128 128 /gate/actor/MyActor/setPosition    0 0 0 mm

/gate/physics/addProcess OpticalAbsorption /gate/physics/addProcess OpticalRayleigh /gate/physics/addProcess OpticalBoundary /gate/physics/addProcess OpticalMie /gate/physics/processList Enabled /gate/physics/processList Initialized

/gate/run/initialize

/gate/digitizer/Singles/insert opticaladder   /gate/digitizer/Singles/insert                        readout   /gate/digitizer/Singles/readout/setDepth              2

/gate/source/addSource                          OpticalPhoton_1 gps /gate/source/OpticalPhoton_1/gps/particle opticalphoton /gate/source/OpticalPhoton_1/gps/energytype Mono /gate/source/OpticalPhoton_1/gps/monoenergy  2.2543 eV /gate/source/OpticalPhoton_1/gps/type Volume /gate/source/OpticalPhoton_1/gps/shape Sphere /gate/source/OpticalPhoton_1/gps/radius 0.1 mm /gate/source/OpticalPhoton_1/gps/polarization           1 0 0 /gate/source/OpticalPhoton_1/gps/centre   0 0 0 cm /gate/source/OpticalPhoton_1/setActivity               1000000 becquerel /gate/source/OpticalPhoton_1/gps/angtype              iso /gate/source/list

/gate/output/root/disable

/gate/random/setEngineName MersenneTwister /gate/random/setEngineSeed 123456789 /gate/random/verbose 0

/gate/application/setTimeSlice   1 s /gate/application/setTimeStart   0 s /gate/application/setTimeStop    1 s /gate/application/startDAQ

Thank you in advance for helping me with this issue.

Kind Regards, Behzad

dsarrut commented 4 years ago

thanks ... I forward to people knowledgable about optical simulation ...

sj202988 commented 4 years ago

Why did you attached a phantomSD on the voxelized volume ? And what happen if you comment this line ?

baiw71 commented 4 years ago

Why did you attached a phantomSD on the voxelized volume ? And what happen if you comment this line ?

I wanted to score the hits inside my voxelized phantom and save it as a root file but then I decided it is easier to use FluenceActor. I commented the line and memory leak problem was solved. I don't know if this is a normal behavior or a bug, so I decided to report it.

dsarrut commented 4 years ago

Hello, thanks for reporting. I consider it is a bug. @sj202988 could you investigate or ask people with experience in optical simulation to investigate please?

djboersma commented 4 years ago

I have seen a bunch of similar reports (e.g. #257 and #305 ), and it looked like these issues are solved in develop (and hence in v9.0). Did anyone check this particular issue is indeed similar & solved?

hangyookang commented 4 years ago

I also faced the same MEMORY issue during the optical simulation (Scintillation + Cerenkov) when I attached phantomSD to water phantom (GATEv8.2).

I tried my macro files (radiotherapy + optical simulation) in GATEv9.0, but "scintillation process" does NOT occur.

prietocanalejom commented 4 years ago

I found that when option ImageRegularParametrisedVolume is used, function ConstructOwnSolidAndLogicalVolume allocated memory for mImageData whitout freeing the memory that was previusly allocated, and furthermore, the function is invoqued at every step. As a temporary solution, I allocated the memory only the fiirst time that the function ConstructOwnSolidAndLogicalVolume is invoqued.