your wxCommunicator uses the media-update branche? Visual leak detector
detect only a few leaks (and they are all solved by the next patch), The
newer version of this tool doesnt detect more leaks, are there other tools
to detect leaks?
here is the new version of the patch ( this patch is created using tortoise
SVN so you should not have any problems applying it):
Index: sipXcallLib/examples/PlaceCall/src/PlaceCall.cpp
===================================================================
--- sipXcallLib/examples/PlaceCall/src/PlaceCall.cpp (revision 9488)
+++ sipXcallLib/examples/PlaceCall/src/PlaceCall.cpp (working copy)
@@ -10,8 +10,8 @@
//
// $$
///////////////////////////////////////////////////////////////////////////////
+
#include "PlaceCall.h"
-
#include <assert.h>
#include <stdio.h >
#include <stdlib.h>
@@ -51,7 +51,6 @@
static bool bVideo = false;
#endif
-
void startTribbleListener(const char* szIp);
bool tribbleProc(SIPX_TRANSPORT hTransport,
const char* szDestinationIp,
@@ -546,8 +545,11 @@
sipxLineAdd(g_hInst, szFromIdentity, &g_hLine) ;
if (szUsername && szPassword && szRealm)
- {
+ {
sipxLineAddCredential(g_hLine, szUsername, szPassword, szRealm) ;
+ sipxConfigSetRegisterExpiration(g_hInst, 60);
+ sipxLineRegister(g_hLine, true);
+
}
#if defined(_WIN32) && defined(VIDEO)
if (bVideo)
@@ -750,6 +752,50 @@
}
+void cleanup( char** szPlayTones,
+ char** szSipUrl,
+ char** szFile,
+ char** szFileBuffer,
+ char** szUsername,
+ char** szPassword,
+ char** szRealm,
+ char** szFromIdentity,
+ char** szStunServer,
+ char** szProxy,
+ char** szBindAddr,
+ char** szOutDevice,
+ char** szInDevice,
+ char** szCodec){
+ if( szPlayTones )
+ delete *szPlayTones;
+ if( szSipUrl )
+ delete *szSipUrl;
+ if( szFile )
+ delete *szFile;
+ if( szFileBuffer )
+ delete *szFileBuffer;
+ if( szUsername )
+ delete *szUsername;
+ if( szPassword )
+ delete *szPassword;
+ if( szRealm )
+ delete *szRealm;
+ if( szFromIdentity )
+ delete *szFromIdentity;
+ if( szStunServer )
+ delete *szStunServer;
+ if( szProxy )
+ delete *szProxy;
+ if( szBindAddr )
+ delete *szBindAddr;
+ if( szOutDevice )
+ delete *szOutDevice;
+ if( szInDevice )
+ delete *szInDevice;
+ if( szCodec )
+ delete *szCodec;
+
+}
int local_main(int argc, char* argv[])
{
bool bError = false ;
@@ -783,8 +829,8 @@
&& (iDuration > 0) && (portIsValid(iSipPort)) && (portIsValid(iRtpPort)))
{
// initialize sipx TAPI-like API
- sipxConfigSetLogLevel(LOG_LEVEL_DEBUG) ;
- sipxConfigSetLogFile("PlaceCall.log");
+ // sipxConfigSetLogLevel(LOG_LEVEL_DEBUG) ;
+ // sipxConfigSetLogFile("PlaceCall.log");
sipxInitialize(&g_hInst, iSipPort, iSipPort, -1, iRtpPort,
DEFAULT_CONNECTIONS, DEFAULT_IDENTITY, szBindAddr);
sipxConfigEnableRport(g_hInst, bUseRport) ;
@@ -853,7 +899,7 @@
printf("Error in retrieving number of video codecs\n");
}
#endif // VIDEO
- sipxUnInitialize(g_hInst);
+ sipxUnInitialize (g_hInst);
exit(0);
}
if (szProxy)
@@ -976,7 +1022,9 @@
#if defined(_WIN32) && defined(VIDEO)
PostMessage(hMain, WM_CLOSE, 0, 0L);
#endif
- return (int) bError ;
+ cleanup( &szPlayTones, &szSipUrl, &szFile, &szFileBuffer, &szUsername,
&szPassword,
+ &szRealm, &szFromIdentity, &szStunServer, &szProxy, &szBindAddr,
+ &szOutDevice, &szInDevice, &szCodec);
}
int main(int argc, char* argv[])
Index: sipXcallLib/src/tapi/sipXtapi.cpp
===================================================================
--- sipXcallLib/src/tapi/sipXtapi.cpp (revision 9488)
+++ sipXcallLib/src/tapi/sipXtapi.cpp (working copy)
@@ -69,6 +69,8 @@
#include "mp/MprToSpkr.h"
#endif
+#include "portlibInit.h"
+
// DEFINES
#define MP_SAMPLE_RATE 8000 // Sample rate (don't change)
#define MP_SAMPLES_PER_FRAME 80 // Frames per second (don't change)
@@ -246,7 +248,12 @@
const char* szTLSCertificatePassword,
const char* szDbLocation)
{
- OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxInitialize");
+
+ // create instances of the librarie(s)
+ // sipXportLib
+ portlib::Init();
+
+ OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, "sipxInitialize");
int iActualTLSPort = tlsPort ;
#ifdef LOG_TO_FILE
@@ -814,7 +821,7 @@
// failure to do so could cause a hang, at least it does using the
VoiceEngine media adapter
sipxDestroyMediaFactoryFactory() ;
}
-
+ portlib::Shutdown();
return rc ;
}
/****************************************************************************
Index: sipXportLib/include/os/OsNameDb.h
===================================================================
--- sipXportLib/include/os/OsNameDb.h (revision 9488)
+++ sipXportLib/include/os/OsNameDb.h (working copy)
@@ -39,6 +39,10 @@
{
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
public:
+/* ============================ INITIALISATORS
============================= */
+ //:Creates the spLock instace
+ static void init(void);
+ static void deinit(void);
/* ============================ CREATORS ==================================
*/
Index: sipXportLib/include/os/OsTimerTask.h
===================================================================
--- sipXportLib/include/os/OsTimerTask.h (revision 9488)
+++ sipXportLib/include/os/OsTimerTask.h (working copy)
@@ -40,7 +40,10 @@
{
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
public:
-
+/* ============================ INITIALISATORS
============================= */
+ //:Creates the OsTimerTask::sLock instace
+ static void init(void);
+ static void deinit(void);
/* ============================ CREATORS ==================================
*/
static OsTimerTask* getTimerTask(void);
Index: sipXportLib/include/portlibInit.h
===================================================================
--- sipXportLib/include/portlibInit.h (revision 0)
+++ sipXportLib/include/portlibInit.h (revision 0)
@@ -0,0 +1,26 @@
+// Include file for initializing this librarie
+
+#include "os/OsTimerTask.h"
+#include "os/OsLock.h"
+#include "os/OsNameDb.h"
+#include "utl/UtlLink.h"
+#include "utl/UtlListIterator.h"
+
+
+class portlib{
+private:
+ // instance pointer
+ static portlib* PortLibInstance;
+ // constructor no arguments
+ portlib();
+ // destructor no arguments
+ ~portlib();
+ // the initcounter should be static because it is used for counting the
+ // created objects.
+ static int initcounter;
+public:
+ static OsBSem* OsTimerTaskLock;
+ static UtlChainPool* linkPairPool;
+ static void Init( void );
+ static void Shutdown( void );
+};
\ No newline at end of file
Index: sipXportLib/include/utl/UtlContainer.h
===================================================================
--- sipXportLib/include/utl/UtlContainer.h (revision 9488)
+++ sipXportLib/include/utl/UtlContainer.h (working copy)
@@ -42,6 +42,11 @@
static const UtlContainableType TYPE ; /** < Class type used for runtime
checking */
+/* ============================ INITIALISATORS
============================= */
+ //:Creates the spIteratorConnectionLock instace
+ static void init(void);
+ static void deinit(void);
+
/* ============================ CREATORS ==================================
*/
/**
Index: sipXportLib/include/utl/UtlLink.h
===================================================================
--- sipXportLib/include/utl/UtlLink.h (revision 9488)
+++ sipXportLib/include/utl/UtlLink.h (working copy)
@@ -236,6 +236,10 @@
{
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
public:
+ /* ============================ INITIALISATORS
============================= */
+ //:Creates the spIteratorConnectionLock instace
+ static void init(void);
+ static void deinit(void);
// ================================================================
/** @name Traversal Operations
@@ -449,6 +453,11 @@
/// Associate a key object (the parent UtlLink data) with its value object.
class UtlPair : public UtlLink
{
+ public:
+ /* ============================ INITIALISATORS
============================= */
+ //:Creates the spPairPool instace
+ static void init(void);
+ static void deinit(void);
protected:
friend class UtlHashMap;
friend class UtlHashMapIterator;
Index: sipXportLib/include/utl/UtlListIterator.h
===================================================================
--- sipXportLib/include/utl/UtlListIterator.h (revision 9488)
+++ sipXportLib/include/utl/UtlListIterator.h (working copy)
@@ -38,7 +38,10 @@
{
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
public:
-
+/* ============================ INITIALISATORS
============================= */
+ //:Creates the UtlListIterator instace
+ static void init(void);
+ static void deinit(void);
/* ============================ CREATORS ==================================
*/
/**
Index: sipXportLib/src/os/OsNameDb.cpp
===================================================================
--- sipXportLib/src/os/OsNameDb.cpp (revision 9488)
+++ sipXportLib/src/os/OsNameDb.cpp (working copy)
@@ -28,10 +28,23 @@
// STATIC VARIABLE INITIALIZATIONS
OsNameDb* OsNameDb::spInstance = NULL;
-OsBSem* OsNameDb::spLock = new OsBSem(OsBSem::Q_PRIORITY, OsBSem::FULL);
+OsBSem* OsNameDb::spLock;
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
+/* ============================ INITIALISATORS
============================= */
+ // Creates the spLock
+void OsNameDb::init(void){
+ OsNameDb::spLock = new OsBSem(OsBSem::Q_PRIORITY, OsBSem::FULL);
+}
+
+void OsNameDb::deinit(void){
+ if( OsNameDb::spLock ){
+ delete OsNameDb::spLock;
+ OsNameDb::spLock = NULL;
+ }
+}
+
/* ============================ CREATORS ==================================
*/
// Return a pointer to the singleton object, creating it if necessary
Index: sipXportLib/src/os/OsTimerTask.cpp
===================================================================
--- sipXportLib/src/os/OsTimerTask.cpp (revision 9488)
+++ sipXportLib/src/os/OsTimerTask.cpp (working copy)
@@ -33,12 +33,23 @@
// Create a semaphore at run time rather than declaring a static semaphore,
// so that the shut-down code does not try to destroy the semaphore,
// which can lead to problems with the ordering of destructors.
-OsBSem* OsTimerTask::sLock =
- new OsBSem(OsBSem::Q_PRIORITY, OsBSem::FULL);
+OsBSem* OsTimerTask::sLock;
const int OsTimerTask::TIMER_MAX_REQUEST_MSGS = 10000;
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
+/* ============================ INITIALISATORS
============================= */
+ // Creates the spPairPool
+void OsTimerTask::init(void){
+ OsTimerTask::sLock = new OsBSem(OsBSem::Q_PRIORITY, OsBSem::FULL);
+}
+
+void OsTimerTask::deinit(void){
+ if( OsTimerTask::sLock ){
+ delete OsTimerTask::sLock;
+ OsTimerTask::sLock = NULL;
+ }
+}
/* ============================ CREATORS ==================================
*/
// Return a pointer to the timer task, creating it if necessary.
Index: sipXportLib/src/portlibInit.cpp
===================================================================
--- sipXportLib/src/portlibInit.cpp (revision 0)
+++ sipXportLib/src/portlibInit.cpp (revision 0)
@@ -0,0 +1,46 @@
+// used for initilisation of global stuff, semaphores etc.
+
+#include "portlibInit.h "
+
+#ifndef UTLLINK_BLOCK_SIZE
+#define UTLLINK_BLOCK_SIZE 1000
+#endif
+
+int portlib::initcounter = 0;
+portlib* portlib::PortLibInstance = NULL;
+OsBSem* portlib::OsTimerTaskLock = NULL;
+UtlChainPool* portlib::linkPairPool = NULL;
+
+void portlib::Init( void ){
+ if( PortLibInstance == NULL ){
+ PortLibInstance = new portlib();
+ }
+ initcounter++;
+}
+
+void portlib::Shutdown( void ){
+ initcounter--;
+ // no more inits left, remove instance
+ if( initcounter == 0 ){
+ delete PortLibInstance;
+ }
+}
+// private constructor, is only called indirect via Init
+portlib::portlib( void ){
+ OsNameDb::init();
+ UtlListIterator::init();
+ UtlContainer::init();
+ UtlLink::init();
+ UtlPair::init();
+ OsTimerTask::init();
+}
+
+portlib::~portlib( void ){
+ OsNameDb::deinit();
+ UtlListIterator::deinit();
+ UtlContainer::deinit();
+ UtlLink::deinit();
+ UtlPair::deinit();
+ OsTimerTask::deinit();
+}
+
Index: sipXportLib/src/utl/UtlContainer.cpp
===================================================================
--- sipXportLib/src/utl/UtlContainer.cpp (revision 9488)
+++ sipXportLib/src/utl/UtlContainer.cpp (working copy)
@@ -29,10 +29,21 @@
* between modules, and this lock needs to exist until all container and
iterator
* destructors have been run - so we deliberately leak it.
*/
-OsBSem* UtlContainer::spIteratorConnectionLock = new
OsBSem(OsBSem::Q_PRIORITY, OsBSem::FULL);
+OsBSem* UtlContainer::spIteratorConnectionLock;
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
+/* ============================ INITIALISATORS
============================= */
+ // Creates the spIteratorConnectionLock
+void UtlContainer::init(void){
+ UtlContainer::spIteratorConnectionLock = new OsBSem(OsBSem::Q_PRIORITY,
OsBSem::FULL);
+}
+void UtlContainer::deinit(void){
+ if( UtlContainer::spIteratorConnectionLock ){
+ delete UtlContainer::spIteratorConnectionLock;
+ UtlContainer::spIteratorConnectionLock = NULL;
+ }
+}
/* ============================ CREATORS ==================================
*/
// Constructor
Index: sipXportLib/src/utl/UtlLink.cpp
===================================================================
--- sipXportLib/src/utl/UtlLink.cpp (revision 9488)
+++ sipXportLib/src/utl/UtlLink.cpp (working copy)
@@ -213,8 +213,21 @@
};
// The pool of available UtlLinks
-UtlChainPool* UtlLink::spLinkPool = new UtlChainPool(UtlLink::allocate,
UTLLINK_BLOCK_SIZE);
+UtlChainPool* UtlLink::spLinkPool;
+/* ============================ INITIALISATORS
============================= */
+ // Creates the spLinkPool
+void UtlLink::init(void){
+ UtlLink::spLinkPool = new UtlChainPool(UtlLink::allocate,
UTLLINK_BLOCK_SIZE);
+}
+
+void UtlLink::deinit(void){
+ if( UtlLink::spLinkPool ){
+ delete UtlLink::spLinkPool;
+ UtlLink::spLinkPool = NULL;
+ }
+}
+
UtlContainable* UtlLink::unlink()
{
// Take the link block out of its list, and return the data pointer
@@ -348,8 +361,21 @@
// The pool of available UtlPairs
-UtlChainPool* UtlPair::spPairPool = new UtlChainPool(UtlPair::allocate,
UTLLINK_BLOCK_SIZE);
+UtlChainPool* UtlPair::spPairPool;
+/* ============================ INITIALISATORS
============================= */
+ // Creates the spPairPool
+void UtlPair::init(void){
+ UtlPair::spPairPool = new UtlChainPool(UtlPair::allocate,
UTLLINK_BLOCK_SIZE);
+}
+
+void UtlPair::deinit(void){
+ if( UtlPair::spPairPool ){
+ delete UtlPair::spPairPool;
+ UtlPair::spPairPool = NULL;
+ }
+}
+
void UtlPair::allocate(size_t blocksize, ///< number of instances to
allocate
UtlChain* blockList, ///< list header for first instance
UtlChain* pool ///< list header for others
Index: sipXportLib/src/utl/UtlListIterator.cpp
===================================================================
--- sipXportLib/src/utl/UtlListIterator.cpp (revision 9488)
+++ sipXportLib/src/utl/UtlListIterator.cpp (working copy)
@@ -28,11 +28,22 @@
* the iterator would return the first element on the list, because NULL
* designates the state "before the first element".
*/
-const UtlLink* UtlListIterator::NOWHERE = new UtlLink;
+const UtlLink* UtlListIterator::NOWHERE;
UtlLink const* UtlListIterator::OFF_LIST_END = NOWHERE;
/* //////////////////////////// PUBLIC ////////////////////////////////////
*/
+/* ============================ INITIALISATORS
============================= */
+ // Creates the spLock
+void UtlListIterator::init(void){
+ UtlListIterator::NOWHERE = new UtlLink;
+}
+void UtlListIterator::deinit(void){
+ if( UtlListIterator::NOWHERE ){
+ delete UtlListIterator::NOWHERE;
+ UtlListIterator::NOWHERE = NULL;
+ }
+}
/* ============================ CREATORS ==================================
*/
// Constructor
2007/5/8, Jaroslav Libák <[EMAIL PROTECTED]>:
>Wow! I build the latest build from the SIPXtapi repo, I ran the place
call example and I got only 12 memory leaks, that's great! With the
>media-update branch I got over 400 leaks! Are there so many leaks fixed or
is the leak detector not able to detect these leaks in this >version of SipX
Visual leak detector 1.0 doesn't detect all memory leaks. When I run my
wxCommunicator and make a call, i also get ~400 memory leaks. Before my leak
patches, there were like 1200 leaks.
Jaro
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/