Package net.sf.joafip.meminspector.service.inspect

Examples of net.sf.joafip.meminspector.service.inspect.MemInspector$SearchObjectVisitor


  }

  @Override
  protected void setUp() throws Exception { // NOPMD
    super.setUp();
    memInspector = new MemInspector();
  }
View Full Code Here


  }

  @Override
  protected void setUp() throws Exception {// NOPMD
    super.setUp();
    memInspector = new MemInspector();
  }
View Full Code Here

    super();
  }

  private void run() throws MemInspectorException {
    final Random random = new Random();
    final MemInspector memInspector = new MemInspector();
    final Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    for (int count = 0; count < 10000; count++) {
      map.put(count, random.nextInt());
    }
    for (int count = 5000; count < 10000; count++) {
      map.remove(count);
    }
    memInspector.inspect(map, false);
    for (int count = 10000; count < 15000; count++) {
      map.put(count, random.nextInt());
    }
    for (int count = 10000; count < 15000; count++) {
      map.remove(count);
    }
    memInspector.inspect(map, true);
    if (memInspector.added()) {
      final String fileName = "runtime/mem.bin";
      memInspector.serialize(new File(fileName));
      ShowObjectTree.show(fileName);
    }
  }
View Full Code Here

  private MainTestPLinkedTreeSet() {
    super();
  }

  private void run() throws MemInspectorException {
    final MemInspector memInspector = new MemInspector();
    memInspector.addExcludedField(LinkedTreeSupport.class, "key");
    final PLinkedTreeSet<Integer> set = new PLinkedTreeSet<Integer>();
    for (int count = 0; count < 1000; count++) {
      set.add(count);
    }
    checkTree(set.getTree());
    for (int count = 500; count < 1000; count++) {
      set.remove(count);
    }
    checkTree(set.getTree());
    memInspector.inspect(set, false);
    for (int count = 1000; count < 1500; count++) {
      set.add(count);
    }
    checkTree(set.getTree());
    for (int count = 1000; count < 1500; count++) {
      set.remove(count);
    }
    checkTree(set.getTree());
    memInspector.inspect(set, true);
    if (memInspector.added()) {
      final String fileName = "runtime/mem.bin";
      memInspector.serialize(new File(fileName));
      ShowObjectTree.show(fileName);
    }
  }
View Full Code Here

  private MainTestHashSet() {
    super();
  }

  private void run() throws MemInspectorException {
    final MemInspector memInspector = new MemInspector();
    final Set<Integer> set = new HashSet<Integer>();
    for (int count = 0; count < 100000; count++) {
      set.add(count);
    }
    for (int count = 50000; count < 100000; count++) {
      set.remove(count);
    }
    memInspector.inspect(set, false);
    for (int count = 100000; count < 150000; count++) {
      set.add(count);
    }
    for (int count = 100000; count < 150000; count++) {
      set.remove(count);
    }
    memInspector.inspect(set, true);
    if (memInspector.added()) {
      final String fileName = "runtime/mem.bin";
      memInspector.serialize(new File(fileName));
      ShowObjectTree.show(fileName);
    }
  }
View Full Code Here

  private MainTestHashSet2() {
    super();
  }

  private void run() throws MemInspectorException {
    final MemInspector memInspector = new MemInspector();
    final Set<Integer> set = new HashSet<Integer>();
    for (int count = 0; count < 10000; count++) {
      set.add(count);
    }
    set.clear();
    memInspector.inspect(set, false);
    for (int count = 0; count < 20000; count++) {
      set.add(count);
    }
    set.clear();
    memInspector.inspect(set, true);
    if (memInspector.added()) {
      final String fileName = "runtime/mem.bin";
      memInspector.serialize(new File(fileName));
      ShowObjectTree.show(fileName);
    }
  }
View Full Code Here

      IOException, SecurityException, IllegalArgumentException,
      NoSuchFieldException, IllegalAccessException,
      FilePersistenceTooBigForSerializationException, HeapException {
    initialize(pathName, dataManager, useCache);
    final Runtime runtime = Runtime.getRuntime();
    final MemInspector memInspectorForMemory = new MemInspector();
    addTemplate();
    long maxMemUse = 0;
    long maxMemUse2 = 0;
    pageSetSize = 0;
    readCacheMapSize = 0;
    writeCacheMapSize = 0;
    freePageRootNodeSize = 0;
    usedPageRootNodeSize = 0;
    final IDataAccessSession session = filePersistence
        .createDataAccessSession();
    initMemInspector();
    session.open();
    initializeByItemDuration();
    boolean objectAddedInMemory = false;
    long duration = 0;
    final PrintWriter insertLogWriter = new PrintWriter(insertLogFilePath);
    final InputStream inputStream = getClass().getResourceAsStream(
        "/all.txt");
    final BufferedReader reader = new BufferedReader(new InputStreamReader(
        inputStream));
    final long insertStartTime = System.currentTimeMillis();
    int count;
    for (count = 0; (System.currentTimeMillis() - insertStartTime) < 5 * 60 * 1000
        && !objectAddedInMemory && count < numberOfItem + 1; count++) {
      // final ItemTemplateList itemTemplateList =
      // getItemTemplateList(session);
      // final ItemTemplate itemTemplate;
      // switch (identifier % 3) {
      // case 0:
      // itemTemplate = itemTemplateList.getItemTemplate(1);
      // break;
      // case 1:
      // itemTemplate = itemTemplateList.getItemTemplate(2);
      // break;
      // case 2:
      // itemTemplate = itemTemplateList.getItemTemplate(3);
      // break;
      // default:
      // itemTemplate = null;
      // }
      final int identifier = Integer.parseInt(reader.readLine());

      addItem(session, identifier);
      // consistencyCheck();
      insertLogWriter.println(identifier);

      if (count % BATCH_SIZE == BATCH_SIZE - 1) {

        final long startTime = System.currentTimeMillis();
        session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
        final long currentTime = System.currentTimeMillis();
        System.gc();
        objectAddedInMemory = checkObjectAddedInMemory(byItemIndex);
        duration += (currentTime - startTime);
        final long byItem = duration * 1000 / (count + 1);
        final long memUse = runtime.totalMemory()
            - runtime.freeMemory();
        byItemMem[byItemIndex] = (int) (memUse / 1024);
        if (memUse > maxMemUse) {
          maxMemUse = memUse;
        }
        byItemDuration[byItemIndex] = (int) byItem;
        final StringBuilder builder = new StringBuilder();
        builder.append('\n');
        builder.append(duration);
        builder.append(" mS ");
        builder.append(count + 1);
        builder.append(" appened, by item ");
        builder.append(byItem);
        builder.append(" µS\nmem used=");
        builder.append(mem(memUse));
        builder.append("\nmax=     ");
        builder.append(mem(maxMemUse));
        if (OBJ_MEM_SIZE) {
          final long memUse2 = memInspectorForMemory
              .memoryUsed(filePersistence);
          if (memUse2 > maxMemUse2) {// NOPMD
            maxMemUse2 = memUse2;
          }
          byItemMem2[byItemIndex] = (int) (memUse2 / 1024);
View Full Code Here

    filePersistence.close();
  }

  private void initMemInspector() throws MemInspectorException {
    if (MEM_INSPECT) {
      memInspector = new MemInspector();
      MemInspectorJoafipSetup.setup(memInspector);
      // memInspector.inspect(this, false);
      markNew = false;
    }
  }
View Full Code Here

    super(name);
  }

  public void test() throws MemInspectorException, FileNotFoundException {
    /* get the memory inspector service instance */
    final MemInspector memInspector = new MemInspector();
    /* Only interested by creation of object from joafip package class */
    memInspector.setMainPackageName("net.sf.joafip");
    bob1.setBob2(new Bob2());
    /*
     * After doing initialization and some object storing, get the object in
     * memory in initial object map.
     */
    memInspector.inspect(this, false/* markNew */);
    assertFalse("expect no object added", memInspector.added());
    List<NodeForObject> list = memInspector.addedList();
    assertTrue("must not have added object", list.isEmpty());

    /* add an object */
    final Bob3 bob3 = new Bob3();
    bob1.setBob3(bob3);
    /*
     * Get the object in memory and log those added to initially in memory
     */
    memInspector.inspect(this, true/* markNew */);
    /*
     * is there object added
     */
    assertTrue("object added must be found", memInspector.added());

    list = memInspector.addedList();
    if (LOGGER.debugEnabled) {
      final StringBuilder builder = new StringBuilder();
      builder.append("added object:\n");
      for (NodeForObject nodeForObject : list) {
        builder.append(nodeForObject.toString());
View Full Code Here

    }
  }

  private HugeMapPopulate() {
    super();
    memInspector = new MemInspector();
  }
View Full Code Here

TOP

Related Classes of net.sf.joafip.meminspector.service.inspect.MemInspector$SearchObjectVisitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.