1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
lvwei@lvweideMacBook-Pro clion_cpp_demo % docker run -it --rm helloworld valgrind --leak-check=full --show-leak-kinds=all /app/HelloWorld
==1== Memcheck, a memory error detector
==1== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1== Command: /app/HelloWorld
==1==
Hello world!
---Test
name:ksnowlv,age:20
unique_ptr age:1,name:ksnow:0
unique_ptr age:2,name:ksnow:1
unique_ptr age:3,name:ksnow:2
unique_ptr age:4,name:ksnow:3
unique_ptr age:5,name:ksnow:4
unique_ptr age:6,name:ksnow:5
unique_ptr age:7,name:ksnow:6
unique_ptr age:8,name:ksnow:7
unique_ptr age:9,name:ksnow:8
unique_ptr age:10,name:ksnow:9
sharedPersons age:1,name:ksnow:0
sharedPersons age:2,name:ksnow:1
sharedPersons age:3,name:ksnow:2
sharedPersons age:4,name:ksnow:3
sharedPersons age:5,name:ksnow:4
sharedPersons age:6,name:ksnow:5
sharedPersons age:7,name:ksnow:6
sharedPersons age:8,name:ksnow:7
sharedPersons age:9,name:ksnow:8
sharedPersons age:10,name:ksnow:9
1 p1 use_count:1,age:10
2 p1 use_count:2
3 p1 use_count:3
4 p1 use_count:2
thread name:t1,g_total=50005000
thread name:t3,g_total=100010000
thread name:t2,g_total=150015000
g_total=150015000
SetAtomicFlag
func1 do somethings!
clearAtomicFlag
SharedMemoryTest
----pid:12
parent process pid:1,key=5046755,shmid:0
read buf:
child process pid:12,parent process pid:1,key=5046755,shmid:0
write buf:Hello world!
------Test------
顺序遍历
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
反序遍历
19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
删除3 或 5之间
0,
1,
2,
4,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
删除5或 11位置之间
0,
1,
2,
4,
6,
13,
14,
15,
16,
17,
18,
19,
-----TestAsync---
-----ShowMyInfomationmessage:1+2:
---ProcessBigDataTest threadID:102195456
数据处理超时,继续处理中thread_id:67316064
数据处理超时,继续处理中thread_id:67316064
数据处理超时,继续处理中thread_id:67316064
数据处理超时,继续处理中thread_id:67316064
数据处理完成thread_id:67316064
3
-----TestPackagedTask---
-----ShowMyInfomationmessage:
---ProcessBigDataTest threadID:67316064
task result:3
task result:---ProcessBigDataTest threadID:102195456
5
newTask result:9
-----TestPromise---
set my value:ksnow!!!
threadid:1,count:1
threadid:1,count:2
threadid:1,count:3
threadid:1,count:4
threadid:1,count:5
threadid:2,count:6
threadid:2,count:7
threadid:2,count:8
threadid:2,count:9
threadid:2,count:10
TestRecursiveMutex:1
TestRecursiveMutex:1,2
threadid:2,lock success
threadid:3,lock fail
threadid:1,lock fail
threadid:1,lock success
threadid:3,lock fail
threadid:2,lock fail
threadid:3,lock success
threadid:1,lock fail
threadid:2,lock fail
threadid:1,lock success
threadid:2,lock fail
threadid:3,lock fail
threadid:2,lock success
threadid:1,lock success
threadid:3,lock fail
lock success
TestLockGuard:锁被占用!!!
mutex超过作用域名后
TestLockGuard:锁成功!!!
Parent process: wrote data to shared_data =1234
Child process: shared_data =1234
Child process: shared_data2 =5678
==21== Invalid write of size 4
==21== at 0x15648C: main (main.cpp:15)
==21== Address 0x4d6af20 is 0 bytes after a block of size 400 alloc'd
==21== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==21== by 0x15647B: main (main.cpp:13)
==21==
*****
~AtomicTest
*****
*****
*****
*****
*****
*****
==21==
==21== HEAP SUMMARY:
==21== in use at exit: 400 bytes in 1 blocks
==21== total heap usage: 53 allocs, 52 frees, 78,122 bytes allocated
==21==
==21== 400 bytes in 1 blocks are definitely lost in loss record 1 of 1
==21== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==21== by 0x15647B: main (main.cpp:13)
==21==
==21== LEAK SUMMARY:
==21== definitely lost: 400 bytes in 1 blocks
==21== indirectly lost: 0 bytes in 0 blocks
==21== possibly lost: 0 bytes in 0 blocks
==21== still reachable: 0 bytes in 0 blocks
==21== suppressed: 0 bytes in 0 blocks
==21==
==21== For lists of detected and suppressed errors, rerun with: -s
==21== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Parent process: 21
==12== Invalid write of size 4
==12== at 0x15648C: main (main.cpp:15)
==12== Address 0x4d6af20 is 0 bytes after a block of size 400 alloc'd
==12== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==12== by 0x15647B: main (main.cpp:13)
==12==
*****
~AtomicTest
*****
*****
*****
*****
*****
*****
==12==
==12== HEAP SUMMARY:
==12== in use at exit: 400 bytes in 1 blocks
==12== total heap usage: 53 allocs, 52 frees, 78,122 bytes allocated
==12==
==12== 400 bytes in 1 blocks are definitely lost in loss record 1 of 1
==12== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==12== by 0x15647B: main (main.cpp:13)
==12==
==12== LEAK SUMMARY:
==12== definitely lost: 400 bytes in 1 blocks
==12== indirectly lost: 0 bytes in 0 blocks
==12== possibly lost: 0 bytes in 0 blocks
==12== still reachable: 0 bytes in 0 blocks
==12== suppressed: 0 bytes in 0 blocks
==12==
==12== For lists of detected and suppressed errors, rerun with: -s
==12== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
12
------Test------
顺序遍历
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
反序遍历
19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,
删除3 或 5之间
0,
1,
2,
4,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
删除5或 11位置之间
0,
1,
2,
4,
6,
13,
14,
15,
16,
17,
18,
19,
-----TestAsync---
-----ShowMyInfomationmessage:1+2:
---ProcessBigDataTest threadID:102195456
数据处理超时,继续处理中thread_id:67316064
数据处理超时,继续处理中thread_id:67316064
数据处理超时,继续处理中thread_id:67316064
数据处理超时,继续处理中thread_id:67316064
数据处理完成thread_id:67316064
3
-----TestPackagedTask---
-----ShowMyInfomationmessage:
---ProcessBigDataTest threadID:67316064
task result:3
task result:---ProcessBigDataTest threadID:102195456
5
newTask result:9
-----TestPromise---
set my value:ksnow!!!
threadid:2,count:1
threadid:2,count:2
threadid:2,count:3
threadid:2,count:4
threadid:2,count:5
threadid:1,count:6
threadid:1,count:7
threadid:1,count:8
threadid:1,count:9
threadid:1,count:10
TestRecursiveMutex:1
TestRecursiveMutex:1,2
threadid:1,lock success
threadid:2,lock fail
threadid:2,lock success
threadid:3,lock fail
threadid:1,lock fail
threadid:3,lock success
threadid:1,lock success
threadid:2,lock fail
threadid:3,lock fail
threadid:2,lock success
threadid:1,lock success
threadid:3,lock fail
threadid:2,lock success
threadid:3,lock fail
threadid:1,lock fail
lock success
TestLockGuard:锁被占用!!!
mutex超过作用域名后
TestLockGuard:锁成功!!!
Parent process: wrote data to shared_data =1234
Child process: shared_data =1234
Child process: shared_data2 =5678
==30== Invalid write of size 4
==30== at 0x15648C: main (main.cpp:15)
==30== Address 0x4d6af20 is 0 bytes after a block of size 400 alloc'd
==30== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==30== by 0x15647B: main (main.cpp:13)
==30==
*****
~AtomicTest
*****
*****
*****
*****
*****
*****
==30==
==30== HEAP SUMMARY:
==30== in use at exit: 400 bytes in 1 blocks
==30== total heap usage: 53 allocs, 52 frees, 78,122 bytes allocated
==30==
==30== 400 bytes in 1 blocks are definitely lost in loss record 1 of 1
==30== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==30== by 0x15647B: main (main.cpp:13)
==30==
==30== LEAK SUMMARY:
==30== definitely lost: 400 bytes in 1 blocks
==30== indirectly lost: 0 bytes in 0 blocks
==30== possibly lost: 0 bytes in 0 blocks
==30== still reachable: 0 bytes in 0 blocks
==30== suppressed: 0 bytes in 0 blocks
==30==
==30== For lists of detected and suppressed errors, rerun with: -s
==30== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Parent process: 30
==1== Invalid write of size 4
==1== at 0x15648C: main (main.cpp:15)
==1== Address 0x4d6af20 is 0 bytes after a block of size 400 alloc'd
==1== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==1== by 0x15647B: main (main.cpp:13)
==1==
*****
~AtomicTest
*****
*****
*****
*****
*****
*****
==1==
==1== HEAP SUMMARY:
==1== in use at exit: 400 bytes in 1 blocks
==1== total heap usage: 53 allocs, 52 frees, 78,122 bytes allocated
==1==
==1== 400 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1== at 0x4866AE8: operator new[](unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==1== by 0x15647B: main (main.cpp:13)
==1==
==1== LEAK SUMMARY:
==1== definitely lost: 400 bytes in 1 blocks
==1== indirectly lost: 0 bytes in 0 blocks
==1== possibly lost: 0 bytes in 0 blocks
==1== still reachable: 0 bytes in 0 blocks
==1== suppressed: 0 bytes in 0 blocks
==1==
==1== For lists of detected and suppressed errors, rerun with: -s
==1== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
lvwei@lvweideMacBook-Pro clion_cpp_demo %
|