-
Notifications
You must be signed in to change notification settings - Fork 751
/
Copy pathmgmtinit.c
1131 lines (988 loc) · 41.3 KB
/
mgmtinit.c
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright IBM Corp. and others 1998
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
#include "jni.h"
#include "j9.h"
#include "mmhook.h"
#include "mmomrhook.h"
#include "jithook.h"
#include "j9consts.h"
#include "omrgcconsts.h"
#include "j9modron.h"
#include "jcl_internal.h"
#include "mgmtinit.h"
/* required for memset */
#include <string.h>
#include "ut_j9jcl.h"
typedef enum {
CLASS_MEMORY=0,
MISC_MEMORY,
JIT_CODECACHE,
JIT_DATACACHE
} nonHeapMemoryPoolIndex;
static void managementClassLoadCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
#if (defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING))
static void managementClassUnloadCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
#endif
static void managementCompilingStartTime(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementCompilingEndTime(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementThreadStartCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementThreadEndCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static VMINLINE void managementGC(OMR_VMThread *omrVMThread, void *userData, BOOLEAN isEnd);
static void managementGlobalGCStart(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementGlobalGCEnd(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementLocalGCStart(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementLocalGCEnd(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void managementCompactEnd(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData);
static void gcStartEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA *frees, UDATA collectorID);
static void gcEndEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA *frees, UDATA *maxs, UDATA collectorID, OMR_VMThread *omrVMThread);
static jint initMemoryManagement(J9JavaVM *vm);
static U_32 getNumberSupported(U_32 supportedIDs);
static UDATA getArrayIndexFromManagerID(J9JavaLangManagementData *mgmt, UDATA id);
static void getSegmentSizes(J9JavaVM *javaVM, J9MemorySegmentList *segList, U_64 *storedSize, U_64 *storedUsed, U_64 *storedPeakSize, U_64 *storedPeakUsed, BOOLEAN isCodeCacheSegment);
static void updateNonHeapMemoryPoolSizes(J9JavaVM *vm, J9JavaLangManagementData *mgmt, BOOLEAN isGCEnd);
/* initialize java.lang.management data structures and hooks */
jint
managementInit(J9JavaVM *vm)
{
J9HookInterface **vmHooks = NULL;
J9HookInterface **omrGCHooks = NULL;
J9VMThread *walkThread = NULL;
J9JavaLangManagementData *mgmt = NULL;
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
#if defined (J9VM_INTERP_NATIVE_SUPPORT)
J9HookInterface **jitHooks = NULL;
#endif
omrthread_t self = omrthread_self();
PORT_ACCESS_FROM_JAVAVM(vm);
/* allocate management data struct */
vm->managementData = j9mem_allocate_memory(sizeof(J9JavaLangManagementData), J9MEM_CATEGORY_VM_JCL);
mgmt = vm->managementData;
if (NULL == mgmt) {
return JNI_ERR;
}
memset(mgmt, 0, sizeof(J9JavaLangManagementData));
/* init monitor used to protect access to the U64 fields in the management data */
if (omrthread_rwmutex_init(&mgmt->managementDataLock, 0, "management fields lock")) {
return JNI_ERR;
}
if (JNI_ERR == initMemoryManagement(vm)) {
return JNI_ERR;
}
/* init monitor used to wake up the heap threshold notification thread */
if (omrthread_monitor_init(&mgmt->notificationMonitor, 0)) {
return JNI_ERR;
}
mgmt->threadCpuTimeEnabledFlag = 1;
if (0 <= omrthread_get_cpu_time(self)) {
mgmt->isThreadCpuTimeSupported = 1;
} else {
mgmt->isThreadCpuTimeSupported = 0;
}
if (0 <= omrthread_get_self_cpu_time(self)) {
mgmt->isCurrentThreadCpuTimeSupported = 1;
} else {
mgmt->isCurrentThreadCpuTimeSupported = 0;
}
/* isThreadCpuTimeSupported and isCurrentThreadCpuTimeSupported are read-only after this point */
mgmt->vmStartTime = j9time_current_time_millis();
/* vm->memoryManagerFunctions will be NULL if we failed to load the gc dll */
if (NULL == mmFuncs) {
return JNI_ERR;
}
mgmt->initialHeapSize = mmFuncs->j9gc_get_initial_heap_size(vm);
mgmt->maximumHeapSize = mmFuncs->j9gc_get_maximum_heap_size(vm);
/* hook class load and unload */
vmHooks = vm->internalVMFunctions->getVMHookInterface(vm);
if ((*vmHooks)->J9HookRegisterWithCallSite(vmHooks, J9HOOK_VM_INTERNAL_CLASS_LOAD, managementClassLoadCounter, OMR_GET_CALLSITE(), mgmt)) {
return JNI_ERR;
}
#ifdef J9VM_GC_DYNAMIC_CLASS_UNLOADING
if ((*vmHooks)->J9HookRegisterWithCallSite(vmHooks, J9HOOK_VM_CLASSES_UNLOAD, managementClassUnloadCounter, OMR_GET_CALLSITE(), mgmt)) {
return JNI_ERR;
}
#endif
/* hook GC start/end events */
omrGCHooks = mmFuncs->j9gc_get_omr_hook_interface(vm->omrVM);
if ((*omrGCHooks)->J9HookRegisterWithCallSite(omrGCHooks, J9HOOK_MM_OMR_GLOBAL_GC_START, managementGlobalGCStart, OMR_GET_CALLSITE(), vm)) {
return JNI_ERR;
}
if ((*omrGCHooks)->J9HookRegisterWithCallSite(omrGCHooks, J9HOOK_MM_OMR_LOCAL_GC_START, managementLocalGCStart, OMR_GET_CALLSITE(), vm)) {
return JNI_ERR;
}
if ((*omrGCHooks)->J9HookRegisterWithCallSite(omrGCHooks, J9HOOK_MM_OMR_GLOBAL_GC_END, managementGlobalGCEnd, OMR_GET_CALLSITE(), vm)) {
return JNI_ERR;
}
if ((*omrGCHooks)->J9HookRegisterWithCallSite(omrGCHooks, J9HOOK_MM_OMR_LOCAL_GC_END, managementLocalGCEnd, OMR_GET_CALLSITE(), vm)) {
return JNI_ERR;
}
if ((*omrGCHooks)->J9HookRegisterWithCallSite(omrGCHooks, J9HOOK_MM_OMR_COMPACT_END, managementCompactEnd, OMR_GET_CALLSITE(), vm)) {
return JNI_ERR;
}
/* lock the thread list */
omrthread_monitor_enter(vm->vmThreadListMutex);
/* count existing threads */
walkThread = vm->mainThread;
do {
mgmt->liveJavaThreads++;
if (walkThread->privateFlags & J9_PRIVATE_FLAGS_DAEMON_THREAD) {
mgmt->liveJavaDaemonThreads++;
}
} while((walkThread = walkThread->linkNext) != vm->mainThread);
mgmt->totalJavaThreadsStarted = mgmt->liveJavaThreads;
mgmt->peakLiveJavaThreads = mgmt->liveJavaThreads;
/* hook thread create and destroy while holding the thread list mutex, so our initial counts stay correct */
if ((*vmHooks)->J9HookRegisterWithCallSite(vmHooks, J9HOOK_VM_THREAD_CREATED, managementThreadStartCounter, OMR_GET_CALLSITE(), mgmt)) {
omrthread_monitor_exit(vm->vmThreadListMutex);
return JNI_ERR;
}
if ((*vmHooks)->J9HookRegisterWithCallSite(vmHooks, J9HOOK_VM_THREAD_DESTROY, managementThreadEndCounter, OMR_GET_CALLSITE(), mgmt)) {
omrthread_monitor_exit(vm->vmThreadListMutex);
return JNI_ERR;
}
omrthread_monitor_exit(vm->vmThreadListMutex);
#if defined (J9VM_INTERP_NATIVE_SUPPORT)
/* hook jit compile start/end events */
jitHooks = vm->internalVMFunctions->getJITHookInterface(vm);
if (jitHooks) {
if ((*jitHooks)->J9HookRegisterWithCallSite(jitHooks, J9HOOK_JIT_COMPILING_START, managementCompilingStartTime, OMR_GET_CALLSITE(), mgmt)) {
return JNI_ERR;
}
if ((*jitHooks)->J9HookRegisterWithCallSite(jitHooks, J9HOOK_JIT_COMPILING_END, managementCompilingEndTime, OMR_GET_CALLSITE(), mgmt)) {
return JNI_ERR;
}
}
#endif
/* Initialization for OperatingSystemNotificationThread (mgmtos.c)
* OperatingSystemNotificationThread must be a singleton class.
*/
if (J9THREAD_SUCCESS != omrthread_monitor_init(&mgmt->dlparNotificationMonitor, 0)) {
mgmt->dlparNotificationMonitor = NULL;
}
mgmt->dlparNotificationQueue = NULL;
mgmt->dlparNotificationsPending = 0;
mgmt->isCounterPathInitialized = 0;
return 0;
}
static void
managementClassLoadCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9JavaLangManagementData *mgmt = userData;
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
mgmt->totalClassLoads++;
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
#if (defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING))
static void
managementClassUnloadCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9VMClassesUnloadEvent *data = eventData;
J9JavaLangManagementData *mgmt = userData;
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
mgmt->totalClassUnloads += data->classUnloadCount;
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
#endif
static void
managementCompilingStartTime(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9CompilingStartEvent *event = eventData;
J9JavaVM *vm = event->currentThread->javaVM;
PORT_ACCESS_FROM_JAVAVM(vm);
J9JavaLangManagementData *mgmt = userData;
I_64 now;
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
now = j9time_nano_time();
if (0 < mgmt->threadsCompiling) {
mgmt->totalCompilationTime += checkedTimeInterval((U_64)now, (U_64)mgmt->lastCompilationStart) * mgmt->threadsCompiling;
}
mgmt->lastCompilationStart = now;
mgmt->threadsCompiling++;
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
static void
managementCompilingEndTime(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9CompilingEndEvent *event = eventData;
J9JavaVM* vm = event->currentThread->javaVM;
PORT_ACCESS_FROM_JAVAVM(vm);
J9JavaLangManagementData *mgmt = userData;
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
mgmt->totalCompilationTime += checkedTimeInterval((U_64)j9time_nano_time(), (U_64)mgmt->lastCompilationStart);
mgmt->threadsCompiling--;
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
/* tear down java.lang.management data structures and hooks */
void
managementTerminate(J9JavaVM *vm)
{
J9HookInterface **vmHooks = NULL;
J9HookInterface **omrGCHooks = NULL;
J9JavaLangManagementData *mgmt = vm->managementData;
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
#if defined (J9VM_INTERP_NATIVE_SUPPORT)
J9HookInterface **jitHooks;
#endif
PORT_ACCESS_FROM_JAVAVM(vm);
if (NULL == mgmt) {
/* managementInit was never called, we have nothing to clean up */
return;
}
/* unhook class load and unload */
vmHooks = vm->internalVMFunctions->getVMHookInterface(vm);
(*vmHooks)->J9HookUnregister(vmHooks, J9HOOK_VM_INTERNAL_CLASS_LOAD, managementClassLoadCounter, mgmt);
#ifdef J9VM_GC_DYNAMIC_CLASS_UNLOADING
(*vmHooks)->J9HookUnregister(vmHooks, J9HOOK_VM_CLASSES_UNLOAD, managementClassUnloadCounter, mgmt);
#endif
/* vm->memoryManagerFunctions will be NULL if we failed to load the gc dll */
if (NULL != mmFuncs) {
/* unhook GC start/end */
omrGCHooks = mmFuncs->j9gc_get_omr_hook_interface(vm->omrVM);
(*omrGCHooks)->J9HookUnregister(omrGCHooks, J9HOOK_MM_OMR_GLOBAL_GC_START, managementGlobalGCStart, vm);
(*omrGCHooks)->J9HookUnregister(omrGCHooks, J9HOOK_MM_OMR_GLOBAL_GC_END, managementGlobalGCEnd, vm);
(*omrGCHooks)->J9HookUnregister(omrGCHooks, J9HOOK_MM_OMR_LOCAL_GC_START, managementLocalGCStart, vm);
(*omrGCHooks)->J9HookUnregister(omrGCHooks, J9HOOK_MM_OMR_LOCAL_GC_END, managementLocalGCEnd, vm);
(*omrGCHooks)->J9HookUnregister(omrGCHooks, J9HOOK_MM_OMR_COMPACT_END, managementCompactEnd, vm);
}
/* unhook thread start and end */
(*vmHooks)->J9HookUnregister(vmHooks, J9HOOK_VM_THREAD_CREATED, managementThreadStartCounter, mgmt);
(*vmHooks)->J9HookUnregister(vmHooks, J9HOOK_VM_THREAD_DESTROY, managementThreadEndCounter, mgmt);
#if defined (J9VM_INTERP_NATIVE_SUPPORT)
/* unhook jit compile start/end events */
jitHooks = vm->internalVMFunctions->getJITHookInterface(vm);
if (jitHooks) {
(*jitHooks)->J9HookUnregister(jitHooks, J9HOOK_JIT_COMPILING_START, managementCompilingStartTime, mgmt);
(*jitHooks)->J9HookUnregister(jitHooks, J9HOOK_JIT_COMPILING_END, managementCompilingEndTime, mgmt);
}
#endif
/* destroy monitor */
omrthread_rwmutex_destroy(mgmt->managementDataLock);
omrthread_monitor_destroy(mgmt->notificationMonitor);
/* Cleanup for OperatingSystemNotificationThread (mgmtos.c) */
if (NULL != mgmt->dlparNotificationMonitor) {
omrthread_monitor_destroy(mgmt->dlparNotificationMonitor);
}
/* deallocate management data struct */
j9mem_free_memory(mgmt->memoryPools);
j9mem_free_memory(mgmt->garbageCollectors);
j9mem_free_memory(mgmt->nonHeapMemoryPools);
j9mem_free_memory(vm->managementData);
}
static void
managementThreadStartCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9JavaLangManagementData *mgmt = userData;
J9VMThreadCreatedEvent *event = (J9VMThreadCreatedEvent *)eventData;
J9VMThread *vmThread = event->vmThread;
if (NULL != vmThread) {
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
mgmt->totalJavaThreadsStarted++;
mgmt->liveJavaThreads++;
if (mgmt->liveJavaThreads > mgmt->peakLiveJavaThreads) {
mgmt->peakLiveJavaThreads = mgmt->liveJavaThreads;
}
if (J9_PRIVATE_FLAGS_DAEMON_THREAD & vmThread->privateFlags) {
mgmt->liveJavaDaemonThreads++;
}
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
}
static void
managementThreadEndCounter(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9JavaLangManagementData *mgmt = userData;
J9VMThreadDestroyEvent *event = (J9VMThreadDestroyEvent *)eventData;
J9VMThread *vmThread = event->vmThread;
if (NULL != vmThread) {
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
mgmt->liveJavaThreads--;
if (J9_PRIVATE_FLAGS_DAEMON_THREAD & vmThread->privateFlags) {
mgmt->liveJavaDaemonThreads--;
}
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
}
static void
managementGC(OMR_VMThread *omrVMThread, void *userData, BOOLEAN isEnd)
{
J9JavaVM *vm = userData;
UDATA heapSize = 0;
UDATA heapFree = 0;
UDATA heapUsed = 0;
UDATA totals[J9VM_MAX_HEAP_MEMORYPOOL_COUNT];
UDATA frees[J9VM_MAX_HEAP_MEMORYPOOL_COUNT];
UDATA maxs[J9VM_MAX_HEAP_MEMORYPOOL_COUNT];
UDATA collectorID = 0;
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
U_32 supportedMemoryPoolIDs = 0;
U_32 id = 0;
U_32 mask = 0;
UDATA idx = 0;
UDATA count = 0;
collectorID = mmFuncs->j9gc_get_collector_id(omrVMThread);
if (0 == collectorID) {
/* only record data for "stop the world" collector */
return;
}
heapSize = mmFuncs->j9gc_heap_total_memory(vm);
heapFree = mmFuncs->j9gc_heap_free_memory(vm);
heapUsed = heapSize - heapFree;
mmFuncs->j9gc_pools_memory(vm, 0, &totals[0], &frees[0], isEnd);
if (isEnd) {
supportedMemoryPoolIDs = (U_32)mmFuncs->j9gc_allsupported_memorypools(vm);
for (count = 0, mask = 1, idx = 0; count < J9_GC_MANAGEMENT_MAX_POOL; ++count, mask <<= 1) {
id = (supportedMemoryPoolIDs & mask);
if (0 != id) {
maxs[idx] = mmFuncs->j9gc_pool_maxmemory(vm, id);
idx += 1;
}
}
gcEndEvent(vm, heapSize, heapUsed, &totals[0], &frees[0], &maxs[0], collectorID, omrVMThread);
} else {
gcStartEvent(vm, heapSize, heapUsed, &totals[0], &frees[0], collectorID);
}
}
static void
managementGlobalGCStart(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
MM_GlobalGCStartEvent *event = (MM_GlobalGCStartEvent *)eventData;
managementGC(event->currentThread, userData, FALSE);
}
static void managementGlobalGCEnd(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
MM_GlobalGCEndEvent *event = (MM_GlobalGCEndEvent *)eventData;
managementGC(event->currentThread, userData, TRUE);
}
static void managementLocalGCStart(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
MM_LocalGCStartEvent *event = (MM_LocalGCStartEvent*)eventData;
managementGC(event->currentThread, userData, FALSE);
}
static void managementLocalGCEnd(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
MM_LocalGCEndEvent *event = (MM_LocalGCEndEvent*)eventData;
managementGC(event->currentThread, userData, TRUE);
}
static void
managementCompactEnd(J9HookInterface **hook, UDATA eventNum, void *eventData, void *userData)
{
J9JavaVM *vm = userData;
J9JavaLangManagementData *mgmt = vm->managementData;
UDATA idx = 0;
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
for (idx = 0; idx < (UDATA)mgmt->supportedCollectors; ++idx) {
if (0 == (mgmt->garbageCollectors[idx].id & J9VM_MANAGEMENT_GC_LOCAL)) {
mgmt->garbageCollectors[idx].totalCompacts += 1;
break;
}
}
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
}
/* Updates java.lang.management data for the start of a GC. */
static void
gcStartEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA *frees, UDATA collectorID)
{
J9JavaLangManagementData *mgmt = vm->managementData;
J9GarbageCollectorData *gcData = &mgmt->garbageCollectors[getArrayIndexFromManagerID(mgmt, collectorID)];
J9MemoryPoolData *memoryPools = mgmt->memoryPools;
J9MemoryNotification *notification = NULL;
J9MemoryNotification *last = NULL;
J9GarbageCollectionInfo* gcInfo = NULL;
UDATA total = 0;
UDATA used = 0;
UDATA idx = 0;
PORT_ACCESS_FROM_JAVAVM(vm);
/* lock the management struct */
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
/* check the wall clock */
/* the start time in milliseconds since the Java virtual machine was started */
gcInfo = &gcData->lastGcInfo;
gcInfo->startTime = j9time_current_time_millis();
if (gcInfo->startTime < (U_64)mgmt->vmStartTime) {
/* startTime is earlier than vmStartTime in case of wall clock correction while interval is measuring */
gcInfo->startTime = 0;
} else {
gcInfo->startTime -= mgmt->vmStartTime;
}
mgmt->preCollectionHeapSize = heapSize;
mgmt->preCollectionHeapUsed = heapUsed;
for (idx = 0; idx < mgmt->supportedMemoryPools; ++idx) {
J9MemoryPoolData *memoryPool = &memoryPools[idx];
total = totals[idx];
used = totals[idx] - frees[idx];
/* update pre Memory Usage of last GcInfo for the collector */
gcInfo->preUsed[idx] = used;
gcInfo->preCommitted[idx] = total;
gcInfo->preMax[idx] = 0;
if (0 != mgmt->lastGCID) {
J9GarbageCollectorData *lastGcData = &mgmt->garbageCollectors[getArrayIndexFromManagerID(mgmt, mgmt->lastGCID)];
J9GarbageCollectionInfo* lastGcInfo = &lastGcData->lastGcInfo;
gcInfo->preMax[idx] = lastGcInfo->postMax[idx];
}
if (0 == gcInfo->preMax[idx]) {
gcInfo->preMax[idx] = memoryPool->postCollectionMaxSize;
}
/* check the peak usage and update */
if (memoryPool->peakUsed < used) {
memoryPool->peakUsed = used;
memoryPool->peakSize = total;
memoryPool->peakMax = gcInfo->preMax[idx];
}
/* if a heap usage threshold is set, check whether we are above or below */
if (0 < memoryPool->usageThreshold) {
if (memoryPool->usageThreshold < used) {
/* usage above threshold now, was it below threshold last time? */
if (0 == (memoryPool->notificationState & THRESHOLD_EXCEEDED)) {
/* if so, generate a notification and set the flag */
memoryPool->notificationState |= THRESHOLD_EXCEEDED;
memoryPool->usageThresholdCrossedCount++;
/* if the queue is full, silently discard this notification */
if (NOTIFICATION_QUEUE_MAX > mgmt->notificationsPending) {
notification = j9mem_allocate_memory(sizeof(*notification), J9MEM_CATEGORY_VM_JCL);
if (NULL != notification) {
notification->gcInfo = NULL;
notification->usageThreshold = j9mem_allocate_memory(sizeof(*notification->usageThreshold), J9MEM_CATEGORY_VM_JCL);
if (NULL == notification->usageThreshold) {
j9mem_free_memory(notification);
notification = NULL;
}
}
/* in case of allocation failure, silently discard the notification */
if (NULL != notification) {
/* populate the notification data */
notification->type = THRESHOLD_EXCEEDED;
notification->next = NULL;
notification->usageThreshold->poolID = memoryPool->id;
notification->usageThreshold->usedSize = used;
notification->usageThreshold->totalSize = total;
notification->usageThreshold->maxSize = gcInfo->preMax[idx];
notification->usageThreshold->thresholdCrossingCount = memoryPool->usageThresholdCrossedCount;
notification->sequenceNumber = mgmt->notificationCount++;
/* notify the thread that dispatches notifications to Java handlers */
omrthread_monitor_enter(mgmt->notificationMonitor);
/* find the end of the queue and count the entries */
last = mgmt->notificationQueue;
while ((last != NULL) && (last->next != NULL)) {
last = last->next;
}
/* add to queue */
if (NULL == last) {
mgmt->notificationQueue = notification;
last = notification;
} else {
last->next = notification;
}
mgmt->notificationsPending += 1;
omrthread_monitor_notify(mgmt->notificationMonitor);
omrthread_monitor_exit(mgmt->notificationMonitor);
}
}
}
} else {
/* usage below threshold now, was it above threshold last time? */
if (0 != (memoryPool->notificationState & THRESHOLD_EXCEEDED)) {
/* if so, clear the flag */
memoryPool->notificationState &= ~THRESHOLD_EXCEEDED;
}
}
}
}
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
/* update nonHeap memory pools for preCollection */
updateNonHeapMemoryPoolSizes(vm, mgmt, FALSE);
}
static void
verifyMemoryUsageAfterGC(
const char *gcName,
const char *poolName,
I_64 initialSize,
U_64 preUsed,
U_64 preCommitted,
I_64 preMax,
U_64 postUsed,
U_64 postCommitted,
I_64 postMax)
{
/* Error tracepoint for the cases
* the value of init or max is negative but not -1; or
* used is greater than the value of committed; or
* committed is greater than the value of max if max is not -1.
*/
if ((preUsed > preCommitted)
|| ((-1 != preMax) && ((I_64)preCommitted > preMax))
|| (-1 > preMax)
|| (postUsed > postCommitted)
|| ((-1 != postMax) && ((I_64)postCommitted > postMax))
|| (-1 > postMax)
|| (-1 > initialSize)
) {
Trc_JCL_memoryManagement_verifyMemoryUsageAfterGC_memoryUsageError(
gcName,
poolName,
initialSize,
preUsed,
preCommitted,
preMax,
postUsed,
postCommitted,
postMax);
}
Trc_JCL_memoryManagement_verifyMemoryUsageAfterGC_memoryUsage(
gcName,
poolName,
initialSize,
preUsed,
preCommitted,
preMax,
postUsed,
postCommitted,
postMax);
}
/* Updates java.lang.management data for the end of a GC. */
static void
gcEndEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA *frees, UDATA *maxs, UDATA collectorID, OMR_VMThread *omrVMThread)
{
J9JavaLangManagementData *mgmt = vm->managementData;
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
J9GarbageCollectorData *gcData = &mgmt->garbageCollectors[getArrayIndexFromManagerID(mgmt, collectorID)];
J9MemoryPoolData *memoryPools = mgmt->memoryPools;
J9MemoryNotification *notification = NULL;
J9MemoryNotification *last = NULL;
UDATA total = 0;
UDATA used = 0;
UDATA max = 0;
UDATA idx = 0;
U_32 notificationEnabled = 0;
UDATA supportedMemoryPools = mgmt->supportedMemoryPools;
UDATA supportedNonHeapMemoryPools = mgmt->supportedNonHeapMemoryPools;
J9GarbageCollectionInfo* gcInfo = NULL;
PORT_ACCESS_FROM_JAVAVM(vm);
/* lock the management struct */
omrthread_rwmutex_enter_write(mgmt->managementDataLock);
mgmt->lastGCID = (U_32)collectorID;
mgmt->postCollectionHeapSize = heapSize;
mgmt->postCollectionHeapUsed = heapUsed;
gcInfo = &gcData->lastGcInfo;
for (idx = 0; idx < mgmt->supportedMemoryPools; ++idx) {
J9MemoryPoolData *memoryPool = &memoryPools[idx];
total = totals[idx];
used = totals[idx] - frees[idx];
max = maxs[idx];
/* update post Memory Usage of last GcInfo for the collector */
gcInfo->postUsed[idx] = used;
gcInfo->postCommitted[idx] = total;
gcInfo->postMax[idx] = max;
/* check the peak usage and update */
if (memoryPool->peakUsed < used) {
memoryPool->peakUsed = used;
memoryPool->peakSize = total;
memoryPool->peakMax = max;
}
/* if a memory pool collection threshold is set and the memory pool is managed by the collector, check whether we are above or below */
if ((0 < memoryPool->collectionUsageThreshold) && mmFuncs->j9gc_is_managedpool_by_collector(vm, (UDATA)(gcData->id & J9VM_MANAGEMENT_GC_HEAP_ID_MASK), (UDATA)(memoryPool->id & J9VM_MANAGEMENT_POOL_HEAP_ID_MASK))) {
if (memoryPool->collectionUsageThreshold < used) {
/* usage above threshold now, was it below threshold last time? */
if (0 == (memoryPool->notificationState & COLLECTION_THRESHOLD_EXCEEDED)) {
/* if so, generate a notification and set the flag */
memoryPool->notificationState |= COLLECTION_THRESHOLD_EXCEEDED;
memoryPool->collectionUsageThresholdCrossedCount++;
/* if the queue is full, silently discard this notification */
if (NOTIFICATION_QUEUE_MAX > mgmt->notificationsPending) {
notification = j9mem_allocate_memory(sizeof(*notification), J9MEM_CATEGORY_VM_JCL);
/* in case of allocation failure, silently discard the notification */
if (NULL != notification) {
notification->gcInfo = NULL;
notification->usageThreshold = j9mem_allocate_memory(sizeof(*notification->usageThreshold), J9MEM_CATEGORY_VM_JCL);
if (NULL == notification->usageThreshold) {
j9mem_free_memory(notification);
notification = NULL;
}
}
if (NULL != notification) {
/* populate the notification data */
notification->type = COLLECTION_THRESHOLD_EXCEEDED;
notification->next = NULL;
notification->usageThreshold->poolID = memoryPool->id;
notification->usageThreshold->usedSize = used;
notification->usageThreshold->totalSize = total;
notification->usageThreshold->maxSize = max;
notification->usageThreshold->thresholdCrossingCount = memoryPool->collectionUsageThresholdCrossedCount;
notification->sequenceNumber = mgmt->notificationCount++;
/* notify the thread that dispatches notifications to Java handlers */
omrthread_monitor_enter(mgmt->notificationMonitor);
/* find the end of the queue and count the entries */
last = mgmt->notificationQueue;
/* find the end of the queue and count the entries */
while ((NULL != last) && (NULL != last->next)) {
last = last->next;
}
/* add to queue */
if (NULL == last) {
mgmt->notificationQueue = notification;
last = notification;
} else {
last->next = notification;
}
mgmt->notificationsPending += 1;
omrthread_monitor_notify(mgmt->notificationMonitor);
omrthread_monitor_exit(mgmt->notificationMonitor);
}
}
}
} else {
/* usage below threshold now, was it above threshold last time? */
if (0 != (memoryPool->notificationState & COLLECTION_THRESHOLD_EXCEEDED)) {
/* if so, clear the flag */
memoryPool->notificationState &= ~COLLECTION_THRESHOLD_EXCEEDED;
}
}
}
}
/* update the relevant stats */
/* the end time in milliseconds since the Java virtual machine was started */
gcData->lastGcInfo.endTime = j9time_current_time_millis();
if (gcData->lastGcInfo.endTime < (U_64)mgmt->vmStartTime) {
/* endTime is earlier than vmStartTime in case of wall clock correction while interval is measuring */
gcData->lastGcInfo.endTime = 0;
} else {
gcData->lastGcInfo.endTime -= mgmt->vmStartTime;
}
/* endTime is earlier than startTime in case of wall clock correction while interval is measuring */
if (gcData->lastGcInfo.endTime >= gcData->lastGcInfo.startTime) {
gcData->totalGCTime += (gcData->lastGcInfo.endTime - gcData->lastGcInfo.startTime);
} else {
gcData->lastGcInfo.endTime = gcData->lastGcInfo.startTime;
}
/* collectionCount */
gcData->lastGcInfo.index += 1;
gcData->memoryUsed = 0;
for (idx = 0; idx < mgmt->supportedMemoryPools; ++idx) {
if (0 != mmFuncs->j9gc_is_managedpool_by_collector(vm, (gcData->id & J9VM_MANAGEMENT_GC_HEAP_ID_MASK), (memoryPools[idx].id & J9VM_MANAGEMENT_POOL_HEAP_ID_MASK))) {
gcData->memoryUsed += memoryPools[idx].postCollectionUsed;
}
}
gcData->totalMemoryFreed += (I_64)(mgmt->preCollectionHeapUsed - mgmt->postCollectionHeapUsed);
/* update the GC CPU usage */
mmFuncs->j9gc_get_CPU_times(vm, &mgmt->gcMainCpuTime, &mgmt->gcWorkerCpuTime, &mgmt->gcMaxThreads, &mgmt->gcCurrentThreads);
/* update nonHeap memory pools for postCollection */
updateNonHeapMemoryPoolSizes(vm, mgmt, TRUE);
/* update J9GarbageCollectionInfo for the collector */
gcInfo->gcID = gcData->id;
gcInfo->gcAction = mmFuncs->j9gc_get_gc_action(vm, (gcInfo->gcID & J9VM_MANAGEMENT_GC_HEAP_ID_MASK));
gcInfo->gcCause = mmFuncs->j9gc_get_gc_cause(omrVMThread);
gcInfo->arraySize =(U_32) (supportedMemoryPools + supportedNonHeapMemoryPools);
/* heap memory pools */
for (idx = 0; supportedMemoryPools > idx; ++idx) {
J9MemoryPoolData *memoryPool = &memoryPools[idx];
gcInfo->initialSize[idx] = memoryPool->initialSize;
if (mmFuncs->j9gc_is_managedpool_by_collector(vm, (UDATA)(gcData->id & J9VM_MANAGEMENT_GC_HEAP_ID_MASK), (UDATA)(memoryPool->id & J9VM_MANAGEMENT_POOL_HEAP_ID_MASK))) {
/**
* the memoryPool is managed by this collection, update preCollection postCollection Memory Usage of this memory Pool
* gcInfo keep memory Usage before and after this gc
* preCollection postCollection Memory Usage in memoryPool only keep information for the GC, which recycle the memory pool
*/
memoryPool->preCollectionUsed = gcInfo->preUsed[idx];
memoryPool->preCollectionSize = gcInfo->preCommitted[idx];
memoryPool->preCollectionMaxSize = (U_64)gcInfo->preMax[idx];
memoryPool->postCollectionUsed = gcInfo->postUsed[idx];
memoryPool->postCollectionSize = gcInfo->postCommitted[idx];
memoryPool->postCollectionMaxSize = (U_64)gcInfo->postMax[idx];
}
if (TrcEnabled_Trc_JCL_memoryManagement_verifyMemoryUsageAfterGC_memoryUsageError
|| TrcEnabled_Trc_JCL_memoryManagement_verifyMemoryUsageAfterGC_memoryUsage
) {
verifyMemoryUsageAfterGC(
gcData->name,
memoryPool->name,
gcInfo->initialSize[idx],
gcInfo->preUsed[idx],
gcInfo->preCommitted[idx],
gcInfo->preMax[idx],
gcInfo->postUsed[idx],
gcInfo->postCommitted[idx],
gcInfo->postMax[idx]);
}
}
/* non heap memory pools */
for (; supportedMemoryPools + supportedNonHeapMemoryPools > idx; ++idx) {
J9NonHeapMemoryData *nonHeapMemory = &mgmt->nonHeapMemoryPools[idx-supportedMemoryPools];
gcInfo->initialSize[idx] = nonHeapMemory->initialSize;
gcInfo->preUsed[idx] = nonHeapMemory->preCollectionUsed;
gcInfo->preCommitted[idx] = nonHeapMemory->preCollectionSize;
gcInfo->preMax[idx] = nonHeapMemory->maxSize;
gcInfo->postUsed[idx] = nonHeapMemory->postCollectionUsed;
gcInfo->postCommitted[idx] = nonHeapMemory->postCollectionSize;
gcInfo->postMax[idx] = nonHeapMemory->maxSize;
if (TrcEnabled_Trc_JCL_memoryManagement_verifyMemoryUsageAfterGC_memoryUsageError
|| TrcEnabled_Trc_JCL_memoryManagement_verifyMemoryUsageAfterGC_memoryUsage
) {
verifyMemoryUsageAfterGC(
gcData->name,
nonHeapMemory->name,
gcInfo->initialSize[idx],
gcInfo->preUsed[idx],
gcInfo->preCommitted[idx],
gcInfo->preMax[idx],
gcInfo->postUsed[idx],
gcInfo->postCommitted[idx],
gcInfo->postMax[idx]);
}
}
/* garbage collection notification */
notificationEnabled = mgmt->notificationEnabled;
omrthread_rwmutex_exit_write(mgmt->managementDataLock);
if (0 !=notificationEnabled) {
notification = j9mem_allocate_memory(sizeof(*notification), J9MEM_CATEGORY_VM_JCL);
/* in case of allocation failure, silently discard the notification */
if (NULL != notification) {
notification->usageThreshold = NULL;
notification->gcInfo = j9mem_allocate_memory(sizeof(*notification->gcInfo), J9MEM_CATEGORY_VM_JCL);
if (NULL == notification->gcInfo) {
j9mem_free_memory(notification);
notification = NULL;
}
}
if (NULL != notification) {
memcpy(notification->gcInfo, gcInfo, sizeof(*notification->gcInfo));
notification->type = END_OF_GARBAGE_COLLECTION;
notification->next = NULL;
notification->sequenceNumber = mgmt->notificationCount++;
/* notify the thread that dispatches notifications to Java handlers */
omrthread_monitor_enter(mgmt->notificationMonitor);
/* find the end of the queue and count the entries */
last = mgmt->notificationQueue;
/* find the end of the queue and count the entries */
while ((NULL != last) && (NULL != last->next)) {
last = last->next;
}
/* add to queue */
if (NULL == last) {
mgmt->notificationQueue = notification;
last = notification;
} else {
last->next = notification;
}
mgmt->notificationsPending += 1;
omrthread_monitor_notify(mgmt->notificationMonitor);
omrthread_monitor_exit(mgmt->notificationMonitor);
}
}
}
static jint
initMemoryManagement(J9JavaVM *vm)
{
J9JavaLangManagementData *mgmt = vm->managementData;
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
U_32 supportedMemoryPoolIDs = (U_32)mmFuncs->j9gc_allsupported_memorypools(vm);
U_32 supportedCollectorIDs = (U_32)mmFuncs->j9gc_allsupported_garbagecollectors(vm);
U_32 id = 0;
U_32 mask = 0;
UDATA idx = 0;
UDATA count = 0;
UDATA totals[J9VM_MAX_HEAP_MEMORYPOOL_COUNT];
UDATA frees[J9VM_MAX_HEAP_MEMORYPOOL_COUNT];
U_64 used = 0;
J9MemorySegmentList *segList = NULL;
PORT_ACCESS_FROM_JAVAVM(vm);
mgmt->supportedMemoryPools = getNumberSupported(supportedMemoryPoolIDs);
mgmt->supportedCollectors = getNumberSupported(supportedCollectorIDs);
/* initialize Heap memory pools (initSize, maxSize) */
mgmt->memoryPools = j9mem_allocate_memory((sizeof(*mgmt->memoryPools) * mgmt->supportedMemoryPools), J9MEM_CATEGORY_VM_JCL);
if (NULL == mgmt->memoryPools) {
return JNI_ERR;
}
memset(mgmt->memoryPools, 0, (sizeof(*mgmt->memoryPools) * mgmt->supportedMemoryPools));
/* request all supported pool data for initial size */
mmFuncs->j9gc_pools_memory(vm, 0, &totals[0], &frees[0], FALSE);
for (count = 0, mask = 1, idx = 0; count < J9_GC_MANAGEMENT_MAX_POOL; ++count, mask <<= 1) {
id = (supportedMemoryPoolIDs & mask);
if (0 != id) {
strcpy(mgmt->memoryPools[idx].name, mmFuncs->j9gc_pool_name(vm, id));
mgmt->memoryPools[idx].id = (U_32) (id | J9VM_MANAGEMENT_POOL_HEAP);
mgmt->memoryPools[idx].initialSize = totals[idx];
mgmt->memoryPools[idx].preCollectionMaxSize = mmFuncs->j9gc_pool_maxmemory(vm, id);
mgmt->memoryPools[idx].postCollectionMaxSize = mgmt->memoryPools[idx].preCollectionMaxSize;
idx += 1;
}
}
/* initialize Garbage Collectors */
mgmt->garbageCollectors = j9mem_allocate_memory((sizeof(*mgmt->garbageCollectors) * mgmt->supportedCollectors), J9MEM_CATEGORY_VM_JCL);
if (NULL == mgmt->garbageCollectors) {
return JNI_ERR;
}
memset(mgmt->garbageCollectors, 0, (sizeof(*mgmt->garbageCollectors) * mgmt->supportedCollectors));
for (count = 0, mask = 1, idx = 0; count < J9_GC_MANAGEMENT_MAX_COLLECTOR; ++count, mask <<= 1) {
id = supportedCollectorIDs&mask;
if (0 != id) {
strcpy(mgmt->garbageCollectors[idx].name, mmFuncs->j9gc_garbagecollector_name(vm, id));
mgmt->garbageCollectors[idx].id = (U_32) (id | J9VM_MANAGEMENT_GC_HEAP);
if (mmFuncs->j9gc_is_local_collector(vm, id)) {
mgmt->garbageCollectors[idx].id |= J9VM_MANAGEMENT_GC_LOCAL;
}
idx += 1;
}
}
/* initialize nonHeap memory pools (initSize) */
mgmt->supportedNonHeapMemoryPools = 2; /* "class storage", "miscellaneous non-heap storage" */
#if defined( J9VM_INTERP_NATIVE_SUPPORT )
if (vm->jitConfig) {
mgmt->supportedNonHeapMemoryPools += 2; /* "JIT code cache", "JIT data cache" */
}
#endif
mgmt->nonHeapMemoryPools = j9mem_allocate_memory((sizeof(*mgmt->nonHeapMemoryPools) * mgmt->supportedNonHeapMemoryPools), J9MEM_CATEGORY_VM_JCL);
if (NULL == mgmt->nonHeapMemoryPools) {
return JNI_ERR;
}
memset(mgmt->nonHeapMemoryPools, 0, (sizeof(*mgmt->nonHeapMemoryPools) * mgmt->supportedNonHeapMemoryPools));
for (idx = 0; idx < mgmt->supportedNonHeapMemoryPools; idx++) {
switch (idx) {
case CLASS_MEMORY:
mgmt->nonHeapMemoryPools[idx].id = J9VM_MANAGEMENT_POOL_NONHEAP_SEG_CLASSES;
strcpy(mgmt->nonHeapMemoryPools[idx].name, J9VM_MANAGEMENT_NONHEAPPOOL_NAME_CLASSES);
segList = vm->classMemorySegments;
mgmt->nonHeapMemoryPools[idx].maxSize = -1;
break;
case MISC_MEMORY:
mgmt->nonHeapMemoryPools[idx].id = J9VM_MANAGEMENT_POOL_NONHEAP_SEG_MISC;
strcpy(mgmt->nonHeapMemoryPools[idx].name, J9VM_MANAGEMENT_NONHEAPPOOL_NAME_MISC);
segList = vm->memorySegments;
mgmt->nonHeapMemoryPools[idx].maxSize = -1;
break;
case JIT_CODECACHE: