Problem running TMVA

I am new to TMVA. So far, I define my signal and background region and prepare an output to use for TMVA. I am using BDT(boosted decision tree) method.
My question is when I using the small size samples (10000000 events)to do the training and testing, the MVA works. However, if I change the larger size samples (40000000 events)to training, the training will break down, seems like:

[sheny@lxplus784 HZg]$ root -l HZg_mva.c
root [0]
Processing HZg_mva.c...
input signal file
debug
DataSetInfo              : [dataset] : Added class "Signal"
                         : Add Tree mEvent of type Signal with 14342801 events
                         : Add Tree mEvent of type Signal with 36318813 events
DataSetInfo              : [dataset] : Added class "Background"
                         : Add Tree mEvent of type Background with 66930010 events
Factory                  : Booking method: BDT
                         :
[sheny@lxplus784 HZg]$

I do not think the problem is in the code itself.
Can someone help me, please?
Here is my MVAcode:HZg_mva.c (4.2 KB)

Hi and welcome to the forums!

This could be a memory issue. TMVA by design loads all data into memory before processing, especially when it “works fine” with the smaller size.

You could verify this using a command like top -o MEM, free, or memusage (pending availability on your system).

Cheers,
Kim