|
From: <ust...@us...> - 2009-04-20 12:54:21
|
Revision: 2996
http://clucene.svn.sourceforge.net/clucene/?rev=2996&view=rev
Author: ustramooner
Date: 2009-04-20 12:54:17 +0000 (Mon, 20 Apr 2009)
Log Message:
-----------
support dmalloc. a few linux fixes
Modified Paths:
--------------
branches/lucene2_3_2/CMakeLists.txt
branches/lucene2_3_2/INSTALL
branches/lucene2_3_2/cmake/DefineOptions.cmake
branches/lucene2_3_2/src/contribs/benchmarker/CMakeLists.txt
branches/lucene2_3_2/src/contribs/contribs-lib-test/CMakeLists.txt
branches/lucene2_3_2/src/contribs-lib/CMakeLists.txt
branches/lucene2_3_2/src/core/CLucene/index/SegmentTermEnum.cpp
branches/lucene2_3_2/src/core/CLucene/index/_SegmentHeader.h
branches/lucene2_3_2/src/core/CMakeLists.txt
branches/lucene2_3_2/src/demo/CMakeLists.txt
branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h
branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h
branches/lucene2_3_2/src/shared/CMakeLists.txt
branches/lucene2_3_2/src/test/CMakeLists.txt
branches/lucene2_3_2/src/test/testall.cpp
Modified: branches/lucene2_3_2/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -50,6 +50,9 @@
OPTION(DISABLE_MULTITHREADING
"disable multithreading - remove all locking code"
OFF)
+OPTION(ENABLE_DMALLOC
+ "enable dmalloc memory leak checker"
+ OFF)
OPTION(ENABLE_ASCII_MODE
"enable ascii support"
OFF)
Modified: branches/lucene2_3_2/INSTALL
===================================================================
--- branches/lucene2_3_2/INSTALL 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/INSTALL 2009-04-20 12:54:17 UTC (rev 2996)
@@ -140,6 +140,21 @@
#valgrind --leak-check=full <program>
+Memory leak tracking with dmalloc
+---------------------------------
+dmalloc (http://dmalloc.com/) is also a nice tool for finding memory leaks.
+To enable, set the ENABLE_DMALLOC flag to ON in cmake. You will of course
+have to have the dmalloc lib installed for this to work.
+
+The cl_test file will by default print a low number of errors and leaks into
+the dmalloc.log.txt file (however, this has a tendency to print false positives).
+You can override this by setting your environment variable DMALLOC_OPTIONS.
+See http://dmalloc.com/ or dmalloc --usage for more information on how to use dmalloc
+
+For example:
+# DMALLOC_OPTIONS=medium,log=dmalloc.log.txt
+# export DMALLOC_OPTIONS
+
Performance with gprof
----------------------
Compile with gprof turned on (ENABLE_GPROF in cmake gui or using ccmake).
Modified: branches/lucene2_3_2/cmake/DefineOptions.cmake
===================================================================
--- branches/lucene2_3_2/cmake/DefineOptions.cmake 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/cmake/DefineOptions.cmake 2009-04-20 12:54:17 UTC (rev 2996)
@@ -1,26 +1,35 @@
#define global options, this makes it easy to use ccmake, or the cmake gui
-MACRO (DEFINE_OPTIONS extraOptions)
- IF(ENABLE_DEBUG)
- SET (${extraOptions} "${${extraOptions}} -D_DEBUG")
- ENDIF(ENABLE_DEBUG)
-
- IF(ENABLE_MMAP)
- SET (${extraOptions} "${${extraOptions}} -DLUCENE_FS_MMAP")
- ENDIF(ENABLE_MMAP)
-
- IF(DISABLE_MULTITHREADING)
- SET (${extraOptions} "${${extraOptions}} -D_CL_DISABLE_MULTITHREADING")
- ELSE(DISABLE_MULTITHREADING)
- SET(${extraOptions} "${${extraOptions}} -D_REENTRANT")
- ENDIF(DISABLE_MULTITHREADING)
-
- IF(ENABLE_ASCII_MODE)
- SET (${extraOptions} "${${extraOptions}} -D_ASCII")
- ELSE(ENABLE_ASCII_MODE)
- SET (${extraOptions} "${${extraOptions}} -D_UCS2")
- SET (${extraOptions} "${${extraOptions}} -D_UNICODE")
- ENDIF(ENABLE_ASCII_MODE)
+MACRO (DEFINE_OPTIONS extraOptions extraLibs)
+ IF(ENABLE_DEBUG)
+ SET (${extraOptions} "${${extraOptions}} -D_DEBUG")
+ ENDIF(ENABLE_DEBUG)
+ IF(ENABLE_MMAP)
+ SET (${extraOptions} "${${extraOptions}} -DLUCENE_FS_MMAP")
+ ENDIF(ENABLE_MMAP)
+
+ IF(ENABLE_DMALLOC)
+ SET (${extraOptions} "${${extraOptions}} -DDMALLOC")
+ IF ( DISABLE_MULTITHREADING )
+ SET (${extraLibs} ${${extraLibs}} "dmalloccxx")
+ ELSE( DISABLE_MULTITHREADING )
+ SET (${extraLibs} ${${extraLibs}} "dmallocthcxx")
+ ENDIF ( DISABLE_MULTITHREADING )
+ ENDIF(ENABLE_DMALLOC)
+
+ IF(DISABLE_MULTITHREADING)
+ SET (${extraOptions} "${${extraOptions}} -D_CL_DISABLE_MULTITHREADING")
+ ELSE(DISABLE_MULTITHREADING)
+ SET(${extraOptions} "${${extraOptions}} -D_REENTRANT")
+ ENDIF(DISABLE_MULTITHREADING)
+
+ IF(ENABLE_ASCII_MODE)
+ SET (${extraOptions} "${${extraOptions}} -D_ASCII")
+ ELSE(ENABLE_ASCII_MODE)
+ SET (${extraOptions} "${${extraOptions}} -D_UCS2")
+ SET (${extraOptions} "${${extraOptions}} -D_UNICODE")
+ ENDIF(ENABLE_ASCII_MODE)
+
IF ( MSVC80 OR MSVC90)
#todo: remove this once crt functions are fixed...
SET (${extraOptions} "${${extraOptions}} -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE")
Modified: branches/lucene2_3_2/src/contribs/benchmarker/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/contribs/benchmarker/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/contribs/benchmarker/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -1,7 +1,7 @@
PROJECT(clucene-benchmarker)
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS})
file(GLOB_RECURSE benchmarker_HEADERS ${clucene-benchmarker_SOURCE_DIR}/*.h)
@@ -17,4 +17,4 @@
)
ADD_EXECUTABLE(cl_benchmarker EXCLUDE_FROM_ALL ${benchmarker_files} )
-TARGET_LINK_LIBRARIES(cl_benchmarker clucene-core clucene-shared)
+TARGET_LINK_LIBRARIES(cl_benchmarker clucene-core clucene-shared ${EXTRA_LIBS})
Modified: branches/lucene2_3_2/src/contribs/contribs-lib-test/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/contribs/contribs-lib-test/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/contribs/contribs-lib-test/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -1,7 +1,7 @@
PROJECT(clucene-contribs-lib-test)
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS})
INCLUDE_DIRECTORIES( ${clucene-contribs-lib-test_SOURCE_DIR} )
@@ -29,5 +29,5 @@
#link the executable against the releavent clucene-shared library (if we aren't using the object files)
IF ( NOT USE_SHARED_OBJECT_FILES )
- TARGET_LINK_LIBRARIES(cl_contribs-lib-test clucene-core clucene-shared clucene-contribs-lib)
+ TARGET_LINK_LIBRARIES(cl_contribs-lib-test clucene-core clucene-shared clucene-contribs-lib ${EXTRA_LIBS})
ENDIF ( NOT USE_SHARED_OBJECT_FILES )
Modified: branches/lucene2_3_2/src/contribs-lib/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/contribs-lib/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/contribs-lib/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -1,7 +1,7 @@
PROJECT(clucene-contribs-lib)
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS} -DMAKE_CLUCENE_CONTRIBS_LIB)
set(CMAKE_MODULE_PATH "${clucene-contribs-lib_SOURCE_DIR}/cmake")
@@ -71,7 +71,7 @@
./CLucene/snowball/src_c/stem_UTF_8_spanish.c
./CLucene/snowball/src_c/stem_UTF_8_swedish.c
)
-SET ( clucene_contrib_extras clucene-core clucene-shared )
+SET ( clucene_contrib_extra_libs clucene-core clucene-shared ${EXTRA_LIBS})
#find our headers
file(GLOB_RECURSE HEADERS ${clucene-contribs-lib_SOURCE_DIR}/*.h)
@@ -82,7 +82,7 @@
MESSAGE ( FATAL "ZLib not found" )
ENDIF ( NOT ZLIB_FOUND )
INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} )
-SET ( clucene_contrib_extras "${clucene_contrib_extras}" ${ZLIB_LIBRARIES} )
+SET ( clucene_contrib_extra_libs "${clucene_contrib_extra_libs}" ${ZLIB_LIBRARIES} )
find_package(Iconv)
#find_package(Strigi)
@@ -99,7 +99,7 @@
add_library(clucene-contribs-lib SHARED
${clucene_contribs_Files} ${clucene_shared_Files} ${HEADERS}
)
-TARGET_LINK_LIBRARIES(clucene-contribs-lib ${clucene_contrib_extras})
+TARGET_LINK_LIBRARIES(clucene-contribs-lib ${clucene_contrib_extra_libs})
#set properties on the libraries
SET_TARGET_PROPERTIES(clucene-contribs-lib PROPERTIES
Modified: branches/lucene2_3_2/src/core/CLucene/index/SegmentTermEnum.cpp
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/index/SegmentTermEnum.cpp 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/core/CLucene/index/SegmentTermEnum.cpp 2009-04-20 12:54:17 UTC (rev 2996)
@@ -137,7 +137,7 @@
//Delete the buffer if necessary
- free(buffer);
+ if ( buffer != NULL ) free(buffer);
//Delete termInfo if necessary
_CLDELETE(termInfo);
Modified: branches/lucene2_3_2/src/core/CLucene/index/_SegmentHeader.h
===================================================================
--- branches/lucene2_3_2/src/core/CLucene/index/_SegmentHeader.h 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/core/CLucene/index/_SegmentHeader.h 2009-04-20 12:54:17 UTC (rev 2996)
@@ -330,7 +330,7 @@
* @throws IOException
*/
//bool getTermFreqVectors(int32_t docNumber, CL_NS(util)::ObjectArray<TermFreqVector>& result);
- CL_NS(util)::ObjectArray<TermFreqVector>* SegmentReader::getTermFreqVectors(int32_t docNumber);
+ CL_NS(util)::ObjectArray<TermFreqVector>* getTermFreqVectors(int32_t docNumber);
private:
//Open all norms files for all fields
void openNorms(CL_NS(store)::Directory* cfsDir);
Modified: branches/lucene2_3_2/src/core/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/core/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/core/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -2,7 +2,7 @@
#define command line options
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS} -DMAKE_CLUCENE_CORE_LIB)
#add the files to our groups and core
@@ -148,7 +148,7 @@
#link the clucene-core library against the releavent clucene-shared library (if we aren't using the object files)
IF ( NOT USE_SHARED_OBJECT_FILES )
- TARGET_LINK_LIBRARIES(clucene-core clucene-shared)
+ TARGET_LINK_LIBRARIES(clucene-core clucene-shared ${EXTRA_LIBS})
ENDIF ( NOT USE_SHARED_OBJECT_FILES )
Modified: branches/lucene2_3_2/src/demo/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/demo/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/demo/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -1,7 +1,7 @@
PROJECT(cl_demo)
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS})
INCLUDE_DIRECTORIES( ${clucene-demo_SOURCE_DIR} )
@@ -21,4 +21,4 @@
${demo_HEADERS}
)
-TARGET_LINK_LIBRARIES(cl_demo clucene-core clucene-shared)
+TARGET_LINK_LIBRARIES(cl_demo clucene-core clucene-shared ${EXTRA_LIBS})
Modified: branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h
===================================================================
--- branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/shared/CLucene/SharedHeader.h 2009-04-20 12:54:17 UTC (rev 2996)
@@ -87,7 +87,7 @@
#define CL_CLASS_DEF(sub,clazz) namespace lucene { namespace sub{ class clazz; } }
#define CL_CLASS_DEF2(sub,sub2, clazz) namespace lucene { namespace sub{ namespace sub2{ class clazz; } } }
- #define CL_TEMPATE_DEF(sub, clazz, typedefs) namespace lucene { namespace sub{ template<typedefs> class clazz; }}
+ #define CL_TEMPATE_DEF(sub, clazz, typedefs) namespace lucene { namespace sub{ template<typedefs> class clazz; }}
#define CL_TYPE_DEF(sub, clazz, def) namespace lucene { namespace sub{ typedef def clazz; }}
#else
#define CL_NS_DEF(sub)
@@ -170,14 +170,14 @@
////////////////////////////////////////////////////////
-//todo: put this logic in cmake
+//todo: put this logic in cmake
#if defined(_MSC_VER)
#if _MSC_FULL_VER >= 140050320
#define _CL_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
#elif _MSC_VER >= 1300
#define _CL_DEPRECATE_TEXT(_Text) __declspec(deprecated)
#else
- #define _CL_DEPRECATE_TEXT(_Text)
+ #define _CL_DEPRECATE_TEXT(_Text)
#endif
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define _CL_DEPRECATE_TEXT(_Text) __attribute__((__deprecated__))
@@ -196,4 +196,10 @@
//memory handling macros/functions
#include "CLucene/debug/mem.h"
+#ifdef DMALLOC
+ #include <stdlib.h>
+ #include <string.h>
+ #include <dmalloc.h>
+#endif
+
#endif //lucene_sharedheader_h
Modified: branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h
===================================================================
--- branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/shared/CLucene/_SharedHeader.h 2009-04-20 12:54:17 UTC (rev 2996)
@@ -24,6 +24,7 @@
#include "CLucene/LuceneThreads.h"
#include "CLucene/config/repl_tchar.h"
#include "CLucene/config/repl_wchar.h"
+#include "CLucene/config/repl_wctype.h" //replacements for functions
#define cl_min(a,b) ((a)>(b) ? (b) : (a))
#define cl_min3(a,b,c) ((a)<(b) ? ((a)<(c) ? (a) : (c)) : ((b)<(c) ? (b) : (c)))
@@ -56,9 +57,6 @@
//if a wide character is being converted to a ascii character and it
//cannot fit, this character is used instead.
#define LUCENE_OOR_CHAR(c) ((char)(((unsigned short)c)&0xFF))
+
-
-#include "CLucene/config/repl_tchar.h" //replacements for functions
-#include "CLucene/config/repl_wctype.h" //replacements for functions
-
#endif //lucene_internal_sharedheader_h
Modified: branches/lucene2_3_2/src/shared/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/shared/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/shared/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -2,7 +2,7 @@
#define command line options
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS} -DMAKE_CLUCENE_SHARED_LIB)
# include specific modules
@@ -302,6 +302,9 @@
SOVERSION ${CLUCENE_SOVERSION}
COMPILE_DEFINITIONS_DEBUG _DEBUG
)
+IF ( ${EXTRA_LIBS} )
+ TARGET_LINK_LIBRARIES(clucene-shared ${EXTRA_LIBS})
+ENDIF ( ${EXTRA_LIBS} )
install(TARGETS clucene-shared
DESTINATION lib
Modified: branches/lucene2_3_2/src/test/CMakeLists.txt
===================================================================
--- branches/lucene2_3_2/src/test/CMakeLists.txt 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/test/CMakeLists.txt 2009-04-20 12:54:17 UTC (rev 2996)
@@ -1,7 +1,7 @@
PROJECT(clucene-test)
INCLUDE (DefineOptions)
-DEFINE_OPTIONS(EXTRA_OPTIONS)
+DEFINE_OPTIONS(EXTRA_OPTIONS EXTRA_LIBS)
ADD_DEFINITIONS(${EXTRA_OPTIONS})
INCLUDE_DIRECTORIES( ${clucene-test_SOURCE_DIR} )
@@ -53,7 +53,7 @@
#link the executable against the releavent clucene-shared library (if we aren't using the object files)
IF ( NOT USE_SHARED_OBJECT_FILES )
- TARGET_LINK_LIBRARIES(cl_test clucene-core clucene-shared)
+ TARGET_LINK_LIBRARIES(cl_test clucene-core clucene-shared ${EXTRA_LIBS})
ENDIF ( NOT USE_SHARED_OBJECT_FILES )
############################
Modified: branches/lucene2_3_2/src/test/testall.cpp
===================================================================
--- branches/lucene2_3_2/src/test/testall.cpp 2009-04-16 17:00:05 UTC (rev 2995)
+++ branches/lucene2_3_2/src/test/testall.cpp 2009-04-20 12:54:17 UTC (rev 2996)
@@ -39,6 +39,17 @@
_crtBreakAlloc=-1;
#endif
#endif
+
+ #ifdef DMALLOC
+ if ( getenv("DMALLOC_OPTIONS") == NULL ){
+ dmalloc_debug_setup("low,log=dmalloc.log.txt");
+ }else{
+ //apparently cygwin has to have this code....
+ dmalloc_debug_setup(getenv("DMALLOC_OPTIONS"));
+ }
+ #endif
+
+
int ret_result = 0;
int i=0;
int exclude = 0;
@@ -203,8 +214,7 @@
_CLDELETE_CaARRAY(cl_tempDir)
_lucene_shutdown(); //clears all static memory
- //print lucenebase debug
-
+
if ( ret_result != 0 )
return ret_result;
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|