Hello Rooters
I have a simple code (see below testG.C file)
when i run with valgrind a have error that i can understand:
Compilation is done with :
g++ -g -O -fPIC -Wall -pthread -m32 -I/$ROOTSYS/include -I/$ROOTSYS/xmlparser/inc -L$ROOTSYS/lib -rdynamic -c -o testG.o testG.C
g++ testG.o -pthread -m32 -I/$ROOTSYS/include -I/$ROOTSYS/xmlparser/inc -L$ROOTSYS/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPos
tscript -lMatrix -lPhysics -lMathCore -lGui -pthread -lm -ldl -rdynamic -lHtml -lSpectrum -lXMLIO -g -O -lThread -o testG
-------------------------------------------------------------------------------------------------------$
running with valgrind give :
valgrind testG
==922== Memcheck, a memory error detector.
==922== Copyright © 2002-2007, and GNU GPL’d, by Julian Seward et al.
==922== Using LibVEX rev 1732, a library for dynamic binary translation.
==922== Copyright © 2004-2007, and GNU GPL’d, by OpenWorks LLP.
==922== Using valgrind-3.2.3, a dynamic binary instrumentation framework.
==922== Copyright © 2000-2007, and GNU GPL’d, by Julian Seward et al.
==922== For more details, rerun with: -v
==922==
==922== Syscall param writev(vector[…]) points to uninitialised byte(s)
==922== at 0x4A9078: writev (in /lib/libc-2.7.so)
==922== by 0x2AC312: (within /usr/lib/libxcb.so.1.0.0)
==922== by 0x2AC85A: (within /usr/lib/libxcb.so.1.0.0)
==922== by 0x2AC98C: (within /usr/lib/libxcb.so.1.0.0)
==922== by 0x2ACADE: xcb_flush (in /usr/lib/libxcb.so.1.0.0)
==922== by 0x2D80E66: _XSend (in /usr/lib/libX11.so.6.2.0)
==922== by 0x2D6EC6A: XQueryExtension (in /usr/lib/libX11.so.6.2.0)
==922== by 0x2D63A2A: XInitExtension (in /usr/lib/libX11.so.6.2.0)
==922== by 0xC88CDF: XFixesFindDisplay (in /usr/lib/libXfixes.so.3.1.0)
==922== by 0xC876FE: XFixesSetCursorName (in /usr/lib/libXfixes.so.3.1.0)
==922== by 0x93F6D6: XcursorImagesLoadCursor (in /usr/lib/libXcursor.so.1.0.2)
==922== by 0x942D49: XcursorTryShapeCursor (in /usr/lib/libXcursor.so.1.0.2)
==922== Address 0x7A9D30C is 4,596 bytes inside a block of size 8,552 alloc’d
==922== at 0x4004864: calloc (vg_replace_malloc.c:279)
==922== by 0x2AC500: xcb_connect_to_fd (in /usr/lib/libxcb.so.1.0.0)
==922== by 0x2AEBC2: xcb_connect (in /usr/lib/libxcb.so.1.0.0)
==922== by 0x2D8037F: _XConnectXCB (in /usr/lib/libX11.so.6.2.0)
==922== by 0x2D68D68: XOpenDisplay (in /usr/lib/libX11.so.6.2.0)
==922== by 0x794D1CD: TGX11::OpenDisplay(char const*) (in /misc/global/root/root5.26_00fc8/lib/libGX11.so)
==922== by 0x6047958: TGClient::TGClient(char const*) (in /misc/global/root/root5.26_00fc8/lib/libGui.so)
==922== by 0x613E8F3: TRootApplication::TRootApplication(char const*, int*, char**) (in /misc/global/root/root5.26_00fc8/lib/libGui.so)
==922== by 0x6160684: TRootGuiFactory::CreateApplicationImp(char const*, int*, char**) (in /misc/global/root/root5.26_00fc8/lib/libGui.so)
==922== by 0x412D32E: TApplication::InitializeGraphics() (in /misc/global/root/root5.26_00fc8/lib/libCore.so)
==922== by 0x412F705: TApplication::TApplication(char const*, int*, char**, void*, int) (in /misc/global/root/root5.26_00fc8/lib/libCore.so)
==922== by 0x804A1BC: main (testG.C:69)
==922==
==922== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 84 from 1)
==922== malloc/free: in use at exit: 4,677,518 bytes in 85,087 blocks.
==922== malloc/free: 230,551 allocs, 145,464 frees, 17,520,313 bytes allocated.
==922== For counts of detected errors, rerun with: -v
==922== searching for pointers to 85,087 not-freed blocks.
==922== checked 9,055,600 bytes.
==922==
==922== LEAK SUMMARY:
==922== definitely lost: 380 bytes in 8 blocks.
==922== possibly lost: 544,026 bytes in 9,971 blocks.
==922== still reachable: 4,133,112 bytes in 75,108 blocks.
==922== suppressed: 0 bytes in 0 blocks.
==922== Rerun with --leak-check=full to see details of leaked memory.
Thanks for you help!
Luc
testG.C file_________
#include <stdlib.h>
#include <TApplication.h>
#include <TStyle.h>
#include <TString.h>
#include <TGClient.h>
#include <TGFrame.h>
#include <TGButton.h>
#include <RQ_OBJECT.h>
class MyMainFrame{
RQ_OBJECT(“MyMainFrame”)
public:
TGMainFrame * fMain;
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h, UInt_t o );
TGTextButton * fStart;
TGTextButton * fStop;
virtual ~MyMainFrame();
void CloseWindow();
};
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h, UInt_t o) {
fMain = new TGMainFrame(p,w,h,o);
//colors
gStyle->SetPalette(1);
TString toto;
toto.Form("Test ");
fMain->SetWindowName(toto.Data());
TGHorizontalFrame *hframe = new TGHorizontalFrame (fMain,100 ,100);
fStart= new TGTextButton (hframe,"Start");
fStop= new TGTextButton (hframe,"Stop");
hframe->AddFrame(fStart);
hframe->AddFrame(fStop);
fMain->AddFrame (hframe);
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
};
MyMainFrame::~MyMainFrame(){
fMain->Cleanup();
delete (fMain);
}
void MyMainFrame::CloseWindow()
{
// Close Window.
fMain->Cleanup();
}
int main(int argc, char **argv){
TApplication theApp(“App”,&argc,argv);
MyMainFrame MyGraphic(gClient->GetRoot(),10, 10,kMainFrame | kVerticalFrame);
theApp.Run();
return 0;
}