Is there a method to avoid G4UserStackingAction::ClassifyNewTrack processes the same track multi times

as the

I want to trigger ClassifyNewTrack only once but Optical processes suspend the current track if there are enough number of optical photons.
I could use a large std::map<int trackID, int Istracked> to note the tracked track, but it would cause large memory if a shower has too many secondary particles for a event. I need to release the stack of notes when one track is totally ended. Is there a class in G4 to save the info?
without using G4TrackInformation.

By default, G4Scintilllation and G4Cerenkov suspend the primary track when they produce secondaries. I don’t think ClassifyNewTrack is invoked by optical processes–maybe by the kernel. You can disable the suspension of the primary with
/process/optical/cerenkov/setTrackSecondariesFirst false
/process/optical/scintillation/setTrackSecondariesFirst false

but beware, your system memory may fill up.