GetV1() memory leak

All of the events in my analysis tree are weighted. So when I create histograms, I need to populate a histogram with weighted events.

[code]
Long64_t eventsSelected = tree->Draw(fieldList, cuts );

	Double_t *events, *weights;
	
	if( 0 < eventsSelected){
		events = tree->GetV1();
		weights = tree->GetV2();
	}
    
	for(int i=0; i<eventsSelected; ++i){
        hist->Fill( events[i], weights[i] )  ; 
	}
	//delete []events;
	//delete []weights;
	this->deleteHistogramFromRoot(tmpHistName);

	return hist;[/code]

This method is OK but the trouble is if I try to explicitly delete the arrays returned by GetV1() then my code crashes. If I don’t delete them, my code seems to leak memory.

If I call tree->GetV1() do I need to delete the array to avoid leaking memory?

Could you send a concrete example of a leak generated by GetV1?
You should not delete the arrays returned by TTree::GetV1,2, etc.
TTree::Draw creates automatically these internal arrays. They are
automatically created/resized when necessary.

Rene

Thanks for the reply Rene. That’s the information I’m looking for.

I’m sure the leaks must be elsewhere.