Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
5a417414
"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "e0e86b74709e8671bad028974fe2d6b5c271da02"
Unverified
Commit
5a417414
authored
Aug 17, 2023
by
Songqing Zhang
Committed by
GitHub
Aug 17, 2023
Browse files
[Bug] fix memory leak in cpp tests (#6141)
parent
97c3f870
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
src/runtime/workspace_pool.cc
src/runtime/workspace_pool.cc
+2
-0
tests/cpp/message_queue_test.cc
tests/cpp/message_queue_test.cc
+3
-3
tests/cpp/socket_communicator_test.cc
tests/cpp/socket_communicator_test.cc
+6
-6
No files found.
src/runtime/workspace_pool.cc
View file @
5a417414
...
@@ -128,6 +128,8 @@ WorkspacePool::~WorkspacePool() {
...
@@ -128,6 +128,8 @@ WorkspacePool::~WorkspacePool() {
* Comment out the destruct of WorkspacePool, due to Segmentation fault with
* Comment out the destruct of WorkspacePool, due to Segmentation fault with
* MXNet Since this will be only called at the termination of process, not
* MXNet Since this will be only called at the termination of process, not
* manually wiping out should not cause problems.
* manually wiping out should not cause problems.
* Note, this will cause memory leak without the following code, so, maybe
* we need to solve the problem.
*/
*/
// for (size_t i = 0; i < array_.size(); ++i) {
// for (size_t i = 0; i < array_.size(); ++i) {
// if (array_[i] != nullptr) {
// if (array_[i] != nullptr) {
...
...
tests/cpp/message_queue_test.cc
View file @
5a417414
...
@@ -89,9 +89,9 @@ TEST(MessageQueueTest, MultiThread) {
...
@@ -89,9 +89,9 @@ TEST(MessageQueueTest, MultiThread) {
MessageQueue
queue
(
100000
,
kNumOfProducer
);
MessageQueue
queue
(
100000
,
kNumOfProducer
);
EXPECT_EQ
(
queue
.
EmptyAndNoMoreAdd
(),
false
);
EXPECT_EQ
(
queue
.
EmptyAndNoMoreAdd
(),
false
);
EXPECT_EQ
(
queue
.
Empty
(),
true
);
EXPECT_EQ
(
queue
.
Empty
(),
true
);
std
::
vector
<
std
::
thread
*
>
thread_pool
;
std
::
vector
<
std
::
thread
>
thread_pool
(
kNumOfProducer
)
;
for
(
int
i
=
0
;
i
<
kNumOfProducer
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumOfProducer
;
++
i
)
{
thread_pool
.
push_back
(
new
std
::
thread
(
start_add
,
&
queue
,
i
)
)
;
thread_pool
[
i
]
=
std
::
thread
(
start_add
,
&
queue
,
i
);
}
}
for
(
int
i
=
0
;
i
<
kNumOfProducer
*
kNumOfMessage
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumOfProducer
*
kNumOfMessage
;
++
i
)
{
Message
msg
;
Message
msg
;
...
@@ -99,7 +99,7 @@ TEST(MessageQueueTest, MultiThread) {
...
@@ -99,7 +99,7 @@ TEST(MessageQueueTest, MultiThread) {
EXPECT_EQ
(
string
(
msg
.
data
,
msg
.
size
),
string
(
"apple"
));
EXPECT_EQ
(
string
(
msg
.
data
,
msg
.
size
),
string
(
"apple"
));
}
}
for
(
int
i
=
0
;
i
<
kNumOfProducer
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumOfProducer
;
++
i
)
{
thread_pool
[
i
]
->
join
();
thread_pool
[
i
]
.
join
();
}
}
EXPECT_EQ
(
queue
.
EmptyAndNoMoreAdd
(),
true
);
EXPECT_EQ
(
queue
.
EmptyAndNoMoreAdd
(),
true
);
}
}
tests/cpp/socket_communicator_test.cc
View file @
5a417414
...
@@ -44,20 +44,20 @@ static void start_server(int id);
...
@@ -44,20 +44,20 @@ static void start_server(int id);
TEST
(
SocketCommunicatorTest
,
SendAndRecv
)
{
TEST
(
SocketCommunicatorTest
,
SendAndRecv
)
{
// start 10 client
// start 10 client
std
::
vector
<
std
::
thread
*
>
client_thread
;
std
::
vector
<
std
::
thread
>
client_thread
(
kNumSender
)
;
for
(
int
i
=
0
;
i
<
kNumSender
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumSender
;
++
i
)
{
client_thread
.
push_back
(
new
std
::
thread
(
start_client
)
)
;
client_thread
[
i
]
=
std
::
thread
(
start_client
);
}
}
// start 10 server
// start 10 server
std
::
vector
<
std
::
thread
*
>
server_thread
;
std
::
vector
<
std
::
thread
>
server_thread
(
kNumReceiver
)
;
for
(
int
i
=
0
;
i
<
kNumReceiver
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumReceiver
;
++
i
)
{
server_thread
.
push_back
(
new
std
::
thread
(
start_server
,
i
)
)
;
server_thread
[
i
]
=
std
::
thread
(
start_server
,
i
);
}
}
for
(
int
i
=
0
;
i
<
kNumSender
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumSender
;
++
i
)
{
client_thread
[
i
]
->
join
();
client_thread
[
i
]
.
join
();
}
}
for
(
int
i
=
0
;
i
<
kNumReceiver
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kNumReceiver
;
++
i
)
{
server_thread
[
i
]
->
join
();
server_thread
[
i
]
.
join
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment