Search in sources :

Example 1 with OMRMemCategoryPointer

use of com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer in project openj9 by eclipse.

the class MemoryCategoryIterator method iterateCategoryRootSet.

public static Iterator<? extends OMRMemCategoryPointer> iterateCategoryRootSet(J9PortLibraryPointer portLibrary) throws CorruptDataException {
    Map<U32, OMRMemCategoryPointer> rootSetMap = new HashMap<U32, OMRMemCategoryPointer>();
    Iterator<? extends OMRMemCategoryPointer> categoryIt = iterateAllCategories(portLibrary);
    /* Store all categories in a map */
    while (categoryIt.hasNext()) {
        OMRMemCategoryPointer thisCategory = categoryIt.next();
        rootSetMap.put(thisCategory.categoryCode(), thisCategory);
    }
    /* Remove any categories that are listed as children of any other category */
    categoryIt = iterateAllCategories(portLibrary);
    while (categoryIt.hasNext()) {
        OMRMemCategoryPointer thisCategory = categoryIt.next();
        final int numberOfChildren = thisCategory.numberOfChildren().intValue();
        for (int i = 0; i < numberOfChildren; i++) {
            U32 childCode = thisCategory.children().at(i);
            rootSetMap.remove(childCode);
        }
    }
    return Collections.unmodifiableCollection(rootSetMap.values()).iterator();
}
Also used : OMRMemCategoryPointer(com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer) U32(com.ibm.j9ddr.vm29.types.U32) HashMap(java.util.HashMap)

Example 2 with OMRMemCategoryPointer

use of com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer in project openj9 by eclipse.

the class MemoryCategoryIterator method iterateAllCategories.

@SuppressWarnings("unchecked")
public static Iterator<OMRMemCategoryPointer> iterateAllCategories(J9PortLibraryPointer portLibrary) throws CorruptDataException {
    OMRMemCategorySetPointer omr_categories = portLibrary.omrPortLibrary().portGlobals().control().omr_memory_categories();
    OMRMemCategorySetPointer language_categories = portLibrary.omrPortLibrary().portGlobals().control().language_memory_categories();
    if (omr_categories.notNull() && language_categories.notNull()) {
        return IteratorHelpers.combineIterators(new MemoryCategorySetIterator(omr_categories), new MemoryCategorySetIterator(language_categories));
    } else if (omr_categories.notNull()) {
        return new MemoryCategorySetIterator(omr_categories);
    } else if (language_categories.notNull()) {
        return new MemoryCategorySetIterator(language_categories);
    } else {
        return new PortLibraryCategoryIterator(portLibrary);
    }
}
Also used : OMRMemCategorySetPointer(com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategorySetPointer)

Example 3 with OMRMemCategoryPointer

use of com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer in project openj9 by eclipse.

the class NativeMemInfoCommand method printSections.

/**
 * @param next
 * @param level
 * @return size in bytes
 * @throws CorruptDataException
 */
void printSections(OMRMemCategoryPointer next, int level) throws CorruptDataException {
    ComponentSizeAllocation csa = computeSize(next);
    if (csa.size == 0) {
        return;
    }
    printLine(level, next.name().getCStringAtOffset(0), csa.size, csa.allocations);
    final int numberOfChildren = next.numberOfChildren().intValue();
    for (int i = 0; i < numberOfChildren; i++) {
        U32 childCode = next.children().at(i);
        OMRMemCategoryPointer child = OMRMemCategoryHelper.getMemoryCategory(childCode);
        printSections(child, level + 1);
    }
    final long liveBytes = next.liveBytes().longValue();
    if (liveBytes < csa.size && liveBytes != 0) {
        printLine(level + 1, "Other", liveBytes, next.liveAllocations().longValue());
    }
}
Also used : OMRMemCategoryPointer(com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer) U32(com.ibm.j9ddr.vm29.types.U32)

Example 4 with OMRMemCategoryPointer

use of com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer in project openj9 by eclipse.

the class NativeMemInfoCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    this.out = out;
    try {
        Iterator<? extends OMRMemCategoryPointer> categories = MemoryCategoryIterator.iterateCategoryRootSet(DTFJContext.getVm().portLibrary());
        while (categories.hasNext()) {
            OMRMemCategoryPointer next = categories.next();
            printSections(next, 0);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : OMRMemCategoryPointer(com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 5 with OMRMemCategoryPointer

use of com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer in project openj9 by eclipse.

the class NativeMemInfoCommand method computeSize.

private ComponentSizeAllocation computeSize(OMRMemCategoryPointer mcp) throws CorruptDataException {
    ComponentSizeAllocation csa = new ComponentSizeAllocation();
    csa.size += mcp.liveBytes().longValue();
    csa.allocations += mcp.liveAllocations().longValue();
    final int numberOfChildren = mcp.numberOfChildren().intValue();
    for (int i = 0; i < numberOfChildren; i++) {
        U32 childCode = mcp.children().at(i);
        OMRMemCategoryPointer child = OMRMemCategoryHelper.getMemoryCategory(childCode);
        csa.add(computeSize(child));
    }
    return csa;
}
Also used : OMRMemCategoryPointer(com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer) U32(com.ibm.j9ddr.vm29.types.U32)

Aggregations

OMRMemCategoryPointer (com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategoryPointer)5 U32 (com.ibm.j9ddr.vm29.types.U32)4 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 OMRMemCategorySetPointer (com.ibm.j9ddr.vm29.pointer.generated.OMRMemCategorySetPointer)1 HashMap (java.util.HashMap)1