Help on Method/s to create Tree from multi-fold gamma-ray coincidence data

The “his3D” is a “THnSparseF” and you do not use “weights” when filling it so, it should be 4 bytes per bin.
There are 128708567 filled bins so, it should be around 491MB (which is significantly less than 1GB).
Why does it need more than 1 GB then?
Maybe the chunks’ management uses a lot of memory, too?
I’m afraid we need @pcanal for further debugging.

@pcanal … Can one somehow write this histogram in “split” mode (so that the 1GB limit is valid for “independent parts” / “data members” of it only)?

In the meantime, you may try the following “brutal fix” …

  // TFile *f = TFile::Open("cub_sparse_fifT7.root", "RECREATE", "", 101);
  f->cd();
#if 0 /* 0 or 1 */
  his3D->Write(); // warning: we need to "manually" save the THnSparse
#else /* 0 or 1 */
  // save the "his3D" in a tree ...
  TTree *t = new TTree("tree3D", "tree with his3D");
  t->Branch("his3D.", his3D, 32000, 111); // "max" splitting?
  t->Fill();
  t->Write();
  delete t;
#endif /* 0 or 1 */
  f->Write();
  delete f;

and if it goes fine, you can retrieve the histogram using:

{
  TFile *f = TFile::Open("cub_sparse_fifT7.root");
  TTree *t; f->GetObject("tree3D", t);
  THnSparse *his3D = 0;
  t->SetBranchAddress("his3D.", &his3D);
  t->GetEntry(0);
  delete f; // automatically deletes "t", too
  his3D->Print("all"); // "his3D" stays in RAM
}