@pcanal Thanks for your reply.
The origin code I have is too big to show. But this is the piece of code I just tested (on my MacBook with ROOT 6.22/06)
#include "TObject.h"
#include "TClonesArray.h"
#include "TFile.h"
#include "TTree.h"
class ClassB: public TObject {
public:
ClassB() {
m_mem1 = 0.0;
m_mem2 = 1.0;
m_mem3 = 2.0;
m_mem4 = 3.0;
m_mem5 = 4.0;
}
double m_mem1;
double m_mem2;
double m_mem3;
double m_mem4;
double m_mem5;
ClassDef(ClassB,1)
};
class ClassA: public TObject {
public:
ClassA() {
m_array = new TClonesArray("ClassB", 1000000);
}
~ClassA() {
delete m_array;
}
ClassDef(ClassA,1)
private:
TClonesArray* m_array;
};
void fun() {
ClassA* addr = 0;
TFile* tfile = new TFile("test.root","recreate");
TTree* tree = new TTree("test Tree","test Tree");
tree->Branch("test Branch", "ClassA", &addr, 32000, 99);
for (int i = 0; i < 1000000; ++i) {
addr = new ClassA();
tree->Fill();
delete addr;
addr = 0;
}
tree->Write();
tfile->Close();
}
This is the output of executing it in the root session:
root [0] .L TClonesArray.C
root [1] fun()
*** Break *** bus error
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TUnixSystem::DispatchSignals(ESignals) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] SigHandler(ESignals) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] sighandler(int) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] textinput::TerminalConfigUnix::HandleSignal(int) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] (anonymous namespace)::TerminalConfigUnix__handleSignal(int) (no debug info)
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libTree.so] TBranch::FillImpl(ROOT::Internal::TBranchIMTHelper*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libTree.so] TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libTree.so] TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libTree.so] TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libTree.so] TTree::Fill() (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] cling::Interpreter::process(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TApplication::ProcessLine(char const*, bool, int*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libRint.so] TRint::HandleTermInput() (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libRint.so] TTermInputHandler::Notify() (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libRint.so] TTermInputHandler::ReadNotify() (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TUnixSystem::CheckDescriptors() (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TSystem::InnerLoop() (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TSystem::Run() (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libCore.so] TApplication::Run(bool) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/lib/root/libRint.so] TRint::Run(bool) (no debug info)
[/usr/local/Cellar/root/6.22.06_1/bin/root.exe] main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
Root > .q