I think I found a memory leak in G4GeneralParticleSource: whenever one calls AddaSource(w), a new G4SingleParticleSource is allocated and the pointer to it is pushed back into the sourceVector. If one then calls DeleteaSource(i) or ClearAll(), the pointer is erased from sourceVector, but the memory for the G4GeneralParticleSource it points to is never deallocated. I also noticed that while ClearAll() clears the sourceProbability vector, DeleteaSource(i) does not delete any entries in sourceProbability. This is likely also a bug. I recommend fixing DeleteaSource(i) to deallocate the memory for entry i before erasing it, and to handle sourceProbability as well. Then I would recommend rewriting ClearAll() to keep calling DeleteaSource(0) while sourceVector.size() is non-zero so that the behavior of the two functions is always consistent. Jason
The memory leak is very limited and will not cause too much a problem in most simulations. Will look into this later. Jason, it seems you may already have this fixed. If so can you send me your correced code? Fan