Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
32abecfb
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
32abecfb
编写于
11月 14, 2019
作者:
weixin_48148422
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make 'taos_dump_memory_leak' public for java
上级
a5bfb0d6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
11 deletion
+33
-11
src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
+8
-0
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+7
-2
src/inc/tutil.h
src/inc/tutil.h
+2
-1
src/system/detail/src/dnodeService.c
src/system/detail/src/dnodeService.c
+2
-2
src/util/src/tmem.c
src/util/src/tmem.c
+14
-6
未找到文件。
src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
浏览文件 @
32abecfb
...
@@ -17,6 +17,14 @@ extern "C" {
...
@@ -17,6 +17,14 @@ extern "C" {
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_detectMemoryLeakImp
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_detectMemoryLeakImp
(
JNIEnv
*
,
jclass
,
jstring
);
(
JNIEnv
*
,
jclass
,
jstring
);
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method:
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_dumpMemoryLeakImp
(
JNIEnv
*
,
jclass
);
/*
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method: initImp
* Method: initImp
...
...
src/client/src/TSDBJNIConnector.c
浏览文件 @
32abecfb
...
@@ -114,15 +114,20 @@ void jniGetGlobalMethod(JNIEnv *env) {
...
@@ -114,15 +114,20 @@ void jniGetGlobalMethod(JNIEnv *env) {
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_detectMemoryLeakImp
(
JNIEnv
*
env
,
jobject
jobj
,
jstring
jPath
)
{
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_detectMemoryLeakImp
(
JNIEnv
*
env
,
jobject
jobj
,
jstring
jPath
)
{
if
(
jPath
!=
NULL
)
{
if
(
jPath
!=
NULL
)
{
const
char
*
path
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jPath
,
NULL
);
const
char
*
path
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jPath
,
NULL
);
taos_d
ump_memory_leak_at_exit
(
path
);
taos_d
etect_memory_leak
(
path
);
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
jPath
,
path
);
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
jPath
,
path
);
}
else
{
}
else
{
taos_d
ump_memory_leak_at_exit
(
NULL
);
taos_d
etect_memory_leak
(
NULL
);
}
}
jniGetGlobalMethod
(
env
);
jniGetGlobalMethod
(
env
);
}
}
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_dumpMemoryLeakImp
(
JNIEnv
*
env
,
jobject
jobj
)
{
taos_dump_memory_leak
();
jniGetGlobalMethod
(
env
);
}
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_initImp
(
JNIEnv
*
env
,
jobject
jobj
,
jstring
jconfigDir
)
{
JNIEXPORT
void
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_initImp
(
JNIEnv
*
env
,
jobject
jobj
,
jstring
jconfigDir
)
{
if
(
jconfigDir
!=
NULL
)
{
if
(
jconfigDir
!=
NULL
)
{
const
char
*
confDir
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jconfigDir
,
NULL
);
const
char
*
confDir
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jconfigDir
,
NULL
);
...
...
src/inc/tutil.h
浏览文件 @
32abecfb
...
@@ -187,7 +187,8 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, unsigned int inLen, cha
...
@@ -187,7 +187,8 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, unsigned int inLen, cha
char
*
taosIpStr
(
uint32_t
ipInt
);
char
*
taosIpStr
(
uint32_t
ipInt
);
extern
void
taos_dump_memory_leak_at_exit
(
const
char
*
path
);
extern
void
taos_detect_memory_leak
(
const
char
*
path
);
extern
void
taos_dump_memory_leak
();
#if TAOS_MEM_CHECK == 1
#if TAOS_MEM_CHECK == 1
...
...
src/system/detail/src/dnodeService.c
浏览文件 @
32abecfb
...
@@ -64,9 +64,9 @@ int main(int argc, char *argv[]) {
...
@@ -64,9 +64,9 @@ int main(int argc, char *argv[]) {
#if TAOS_MEM_CHECK == 2
#if TAOS_MEM_CHECK == 2
}
else
if
(
strcmp
(
argv
[
i
],
"--check-mem-leak"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"--check-mem-leak"
)
==
0
)
{
if
((
i
<
argc
-
1
)
&&
(
argv
[
i
+
1
][
0
]
!=
'-'
))
{
if
((
i
<
argc
-
1
)
&&
(
argv
[
i
+
1
][
0
]
!=
'-'
))
{
taos_d
ump_memory_leak_at_exit
(
argv
[
++
i
]);
taos_d
etect_memory_leak
(
argv
[
++
i
]);
}
else
{
}
else
{
taos_d
ump_memory_leak_at_exit
(
NULL
);
taos_d
etect_memory_leak
(
NULL
);
}
}
#endif
#endif
}
}
...
...
src/util/src/tmem.c
浏览文件 @
32abecfb
...
@@ -261,11 +261,15 @@ ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char* file,
...
@@ -261,11 +261,15 @@ ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char* file,
return
size
;
return
size
;
}
}
static
void
dump_memory_leak
()
{
void
taos_
dump_memory_leak
()
{
const
char
*
hex
=
"0123456789ABCDEF"
;
const
char
*
hex
=
"0123456789ABCDEF"
;
const
char
*
fmt
=
":%d: addr=0x%p, size=%d, content(first 16 bytes)='"
;
const
char
*
fmt
=
":%d: addr=0x%p, size=%d, content(first 16 bytes)='"
;
size_t
numOfBlk
=
0
,
totalSize
=
0
;
size_t
numOfBlk
=
0
,
totalSize
=
0
;
if
(
fpMemLeak
==
NULL
)
{
return
;
}
fputs
(
"memory blocks allocated but not freed before exit:
\n\n
"
,
fpMemLeak
);
fputs
(
"memory blocks allocated but not freed before exit:
\n\n
"
,
fpMemLeak
);
while
(
atomic_val_compare_exchange_ptr
(
&
lock
,
0
,
1
)
!=
0
);
while
(
atomic_val_compare_exchange_ptr
(
&
lock
,
0
,
1
)
!=
0
);
...
@@ -303,13 +307,13 @@ static void dump_memory_leak() {
...
@@ -303,13 +307,13 @@ static void dump_memory_leak() {
static
void
dump_memory_leak_at_sig
(
int
sig
)
{
static
void
dump_memory_leak_at_sig
(
int
sig
)
{
fprintf
(
fpMemLeak
,
"signal %d received, exiting...
\n
"
,
sig
);
fprintf
(
fpMemLeak
,
"signal %d received, exiting...
\n
"
,
sig
);
dump_memory_leak
();
taos_
dump_memory_leak
();
struct
sigaction
act
=
{
0
};
struct
sigaction
act
=
{
0
};
act
.
sa_handler
=
SIG_DFL
;
act
.
sa_handler
=
SIG_DFL
;
sigaction
(
sig
,
&
act
,
NULL
);
sigaction
(
sig
,
&
act
,
NULL
);
}
}
void
taos_d
ump_memory_leak_at_exit
(
const
char
*
path
)
{
void
taos_d
etect_memory_leak
(
const
char
*
path
)
{
if
(
fpMemLeak
!=
NULL
)
{
if
(
fpMemLeak
!=
NULL
)
{
printf
(
"memory leak detection already enabled.
\n
"
);
printf
(
"memory leak detection already enabled.
\n
"
);
return
;
return
;
...
@@ -322,7 +326,7 @@ void taos_dump_memory_leak_at_exit(const char* path) {
...
@@ -322,7 +326,7 @@ void taos_dump_memory_leak_at_exit(const char* path) {
return
;
return
;
}
}
atexit
(
dump_memory_leak
);
atexit
(
taos_
dump_memory_leak
);
struct
sigaction
act
=
{
0
};
struct
sigaction
act
=
{
0
};
act
.
sa_handler
=
dump_memory_leak_at_sig
;
act
.
sa_handler
=
dump_memory_leak_at_sig
;
...
@@ -334,7 +338,11 @@ void taos_dump_memory_leak_at_exit(const char* path) {
...
@@ -334,7 +338,11 @@ void taos_dump_memory_leak_at_exit(const char* path) {
#endif
#endif
#if TAOS_MEM_CHECK != 2
#if TAOS_MEM_CHECK != 2
void
taos_dump_memory_leak_at_exit
(
const
char
*
path
)
{
void
taos_dump_memory_leak
()
{
printf
(
"memory leak detection not enabled!"
)
// do nothing
}
void
taos_detect_memory_leak
(
const
char
*
path
)
{
printf
(
"memory leak detection not enabled, please set 'TAOS_MEM_CHECK' to 2."
);
}
}
#endif
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录