I have an issue when deleting a histogram pointer when it is allocated to memory using new. Below are the relevant lines of code:
[code]TH1D *h = new TH1D(“h”, “h”, 32, 0, 32);
for (int l = 0; l < 32; l++){
h -> Fill(l);
}
OutFile -> cd();
h -> Write();
delete h;
[/code]
If I run the macro that this code is based off of, it will cause a segmentation fault. However, if I comment out the h-> Write() line there is no segmentation fault. Any thoughts as to why this would happen? I understand that it is good practice to delete every pointer that is allocated using new.