TFile Writing Name=hsimple.root Title=
CustomReAlloc2: oldsize != size
Fatal in <CustomReAlloc2>: unreasonable size (1169)
aborting
*** Error code 134 (bu21)
Java source:
public class First {
public native void callRoot();
static {
System.loadLibrary("first");
}
public static void main(String[] args) {
new First().callRoot();
}
}
C++ source:
#include "TROOT.h"
#include "TObject.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TLine.h"
#include "TPaveLabel.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TNtuple.h"
#include "TRandom.h"
#include "First.h"
#include "stdio.h"
#include "stdlib.h"
extern void InitGui();
VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
int Error; // needed by Motif
TROOT root("prova","Prova", initfuncs);
void Java_First_callRoot(JNIEnv *env, jobject obj) {
int * argc= new int;
*argc=1;
char** argv=new char*;
*argv="app";
TApplication theApp("App",argc,argv);
TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500);
c1->SetFillColor(42);
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(6);
c1->GetFrame()->SetBorderMode(-1);
TFile* hfile = new TFile("hsimple.root","RECREATE");
// Create some histograms, a profile histogram and an ntuple
TH1F *hpx = new TH1F("hpx","This is the px distribution",50,-4,4);
TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
TProfile *hprof = new TProfile("hprof","Profile of pz versus
px",100,-4,4,0,20);
TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
// Set canvas/frame attributes (save old attributes)
hpx->SetFillColor(48);
// Fill histograms randomly
gRandom->SetSeed();
Float_t px, py, pz;
const Int_t kUPDATE = 1000;
for ( Int_t i=0; i<25000; i++) {
gRandom->Rannor(px,py);
pz = px*px + py*py;
Float_t random = gRandom->Rndm(1);
hpx->Fill(px);
hpxpy->Fill(px,py);
hprof->Fill(px,pz);
ntuple->Fill(px,py,pz,random,i);
if (!i%kUPDATE) {
if (i == kUPDATE) hpx->Draw();
c1->Modified();
c1->Update();
}
}
// Save all objects in this file
hpx->SetFillColor(0);
hfile->Write();
hpx->SetFillColor(48);
theApp.Run();
return;
}