VisualVM导致崩溃:“EXCEPTION_ACCESS_VIOLATION”

时间:2015-11-04 14:55:39

标签: java-7 visualvm

我正在尝试使用VisualVM来配置我的程序,但它总是崩溃,通常会出现相同的错误消息:

Waiting...
Profiler Agent: Waiting for connection on port 5140 (Protocol version: 15)
Profiler Agent: Established connection with the tool
Profiler Agent: Local accelerated session

Starting test 0
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000c12e9d20, pid=4808, tid=11472
#
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  0x00000000c12e9d20
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Brendon\workspace\JavaFx\hs_err_pid4808.log
Compiled method (c1)   10245  952       3       pathfinderGameTest.Pathfinder$$Lambda$4/1163157884::get$Lambda (10 bytes)
 total in heap  [0x00000000027d72d0,0x00000000027d7798] = 1224
 relocation     [0x00000000027d73f0,0x00000000027d7430] = 64
 main code      [0x00000000027d7440,0x00000000027d7620] = 480
 stub code      [0x00000000027d7620,0x00000000027d76b0] = 144
 oops           [0x00000000027d76b0,0x00000000027d76b8] = 8
 metadata       [0x00000000027d76b8,0x00000000027d76d0] = 24
 scopes data    [0x00000000027d76d0,0x00000000027d7730] = 96
 scopes pcs     [0x00000000027d7730,0x00000000027d7790] = 96
 dependencies   [0x00000000027d7790,0x00000000027d7798] = 8
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
Profiler Agent: JNI OnLoad Initializing...
Profiler Agent: JNI OnLoad Initialized successfully
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.
Profiler Agent Warning: JVMTI classLoadHook: class name is null.

VisualVM设法给我一个非常快速的快照(约60ms),但我不确定这样的快速测试是多么可靠。

我遵循了https://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient(v=vs.110).aspx条款,但没有改变任何内容。无论如何我都在使用Java7,所以它甚至不应该是一个问题。

这是我试图描述的代码:

package pathfinderGameTest;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.BiConsumer;

import utils.Duple;

public class Pathfinder<T> {

    //To track walls
    Area<T> area;

    public Pathfinder(Area<T> a) {
        area = a;
    }

    /**
     * Preset offsets representing each of the four directions.
     */
    private static final List<Duple<Double>> fourDirectionOffsets = Collections.unmodifiableList(Arrays.asList(
        new Duple<Double>(1.0,0.0), new Duple<Double>(-1.0,0.0), new Duple<Double>(0.0,1.0), new Duple<Double>(0.0,-1.0) ));

    /**
     * Finds a path from aStart to bGoal, taking into consideration walls
     * 
     * @param aStart The start position
     * @param bGoal The goal position
     * @return A list representing the path from the start to the goal
     */
    public List<Duple<Double>> findPathFromAToB(Duple<Double> aStart, Duple<Double> bGoal) {
        Deque<Duple<Double>> frontier = new ArrayDeque<>();
        Map<Duple<Double>, Duple<Double>> cameFrom = new HashMap<>();

        frontier.push(aStart);

        while (!frontier.isEmpty()) {
            Duple<Double> current = frontier.pop();

            if (current.equals(bGoal)) break;

            List<Duple<Double>> neighbors = cellsAround(current, fourDirectionOffsets);

            neighbors.stream()
                .filter(location -> !cameFrom.containsKey(location) && area.cellIsInBounds(location) && area.getCellAt(location) == null)
                .forEach( neighbor -> {
                    frontier.add(neighbor);
                    cameFrom.put(neighbor, current);

                });

        }

        return reconstructPath(cameFrom, aStart, bGoal);
    }

    /**
     * Transforms a backtracking map into a path
     * 
     * @param cameFrom Backtracking map
     * @param start Start position
     * @param goal Goal position
     * @return A list representing the path from the start to the goal
     */
    private static List<Duple<Double>> reconstructPath(Map<Duple<Double>, Duple<Double>> cameFrom, Duple<Double> start, Duple<Double> goal) {
        List<Duple<Double>> path = new ArrayList<>();
        //path.add(goal);

        Duple<Double> current = goal;

        do {
            if (current != goal) {
                path.add(current);
            }

            current = cameFrom.get(current);

        } while (current != null && !current.equals(start));

        Collections.reverse(path);

        return path;
    }

    /**
     * Calculates the cells surrounding pos as indicated by the given offsets
     * @param pos The position to find the surrounding cells of
     * @param offsets Positions relative to pos to check
     * @return
     */
    private static List<Duple<Double>> cellsAround(Duple<Double> pos, List<Duple<Double>> offsets) {
        List<Duple<Double>> surroundingCells = new ArrayList<>();

        /*offsets.stream()
            .map( offset -> pos.map(offset, (x1, x2) -> x1 + x2) )
            .forEach(surroundingCells::add);*/

        for (Duple<Double> offset : offsets) {
            surroundingCells.add( pos.map(offset, (x1, x2) -> x1 + x2) );
        }

        return surroundingCells;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        System.out.println("Waiting...");
        s.nextLine();

        List<Long> times = new ArrayList<>();

        for (int tests = 0; tests < 900; tests++) {
            System.out.println("Starting test " + tests);

            long startT = new Date().getTime();

            Area<Wall> a = new Area<>(500, 500);

            Duple<Double> source = new Duple<>(0.0, 0.0);
            Duple<Double> target = new Duple<>(500.0, 500.0);

            Pathfinder<Wall> p = new Pathfinder<>(a);

            List<Duple<Double>> path = p.findPathFromAToB(source, target);

            times.add( (new Date().getTime()) - startT );
        }

        System.out.println("\n\n");

        long sum = 0;
        for (long t : times) {
            System.out.println(t);
            sum += t;
        }

        System.out.println("Average: " + ((double)sum / times.size() / 1000) + " seconds.");
    }
}

0 个答案:

没有答案
相关问题