Gate icon indicating copy to clipboard operation
Gate copied to clipboard

Memory Leak issue in optical simulations

Open baiw71 opened this issue 5 years ago • 7 comments

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

baiw71 avatar Jan 31 '20 10:01 baiw71

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

dsarrut avatar Feb 12 '20 07:02 dsarrut

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

sj202988 avatar Feb 17 '20 12:02 sj202988

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.

baiw71 avatar Mar 05 '20 15:03 baiw71

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?

dsarrut avatar Mar 09 '20 08:03 dsarrut

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?

djboersma avatar Mar 25 '20 14:03 djboersma

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.

hangyookang avatar Jun 10 '20 07:06 hangyookang

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.

prietocanalejom avatar Jul 26 '20 23:07 prietocanalejom