#fixed code
                             public static void main(String[] args) {
		try {

			// 1. create option parser
			OptionParser parser = createOptionParser();
			OptionSet optionSet = parser.parse(args);

			if (optionSet.has("help")) {
				printHelper(parser);
				System.exit(0);
			}

			// 2. create vminfo
			String pid = parsePid(parser, optionSet);

			VMInfo vminfo = VMInfo.processNewVM(pid);
			if (vminfo.state != VMInfoState.ATTACHED) {
				System.out.println("\nERROR: Could not attach to process, please find reason in README\n");
				return;
			}

			// 3. create view
			VMDetailView.DetailMode displayMode = parseDisplayMode(optionSet);
			Integer width = null;
			if (optionSet.hasArgument("width")) {
				width = (Integer) optionSet.valueOf("width");
			}

			VMDetailView view = new VMDetailView(vminfo, displayMode, width);

			if (optionSet.hasArgument("limit")) {
				Integer limit = (Integer) optionSet.valueOf("limit");
				view.threadLimit = limit;
			}

			// 4. create main application
			VJTop app = new VJTop();
			app.mainThread = Thread.currentThread();
			app.view = view;

			Integer interval = DEFAULT_INTERVAL;
			if (optionSet.hasArgument("interval")) {
				interval = (Integer) (optionSet.valueOf("interval"));
				if (interval < 1) {
					throw new IllegalArgumentException("Interval cannot be set below 1.0");
				}
			}
			app.interval = interval;

			if (optionSet.hasArgument("n")) {
				Integer iterations = (Integer) optionSet.valueOf("n");
				app.maxIterations = iterations;
			}

			// 5. start thread to get user input
			if (app.maxIterations == -1) {
				InteractiveTask task = new InteractiveTask(app);
				if (task.inputEnabled()) {
					view.displayCommandHints = true;

					Thread interactiveThread = new Thread(task, "InteractiveThread");
					interactiveThread.setDaemon(true);
					interactiveThread.start();
				}
			}

			// 6. run app
			app.run(view);
		} catch (Exception e) {
			e.printStackTrace(System.out);
			System.out.flush();
		}
	}
#vulnerable code 
                             public static void main(String[] args) {
		try {

			// 1. create option parser
			OptionParser parser = createOptionParser();
			OptionSet optionSet = parser.parse(args);

			if (optionSet.has("help")) {
				printHelper(parser);
				System.exit(0);
			}

			// 2. create vminfo
			String pid = parsePid(parser, optionSet);

			VMInfo vminfo = VMInfo.processNewVM(pid);
			if (vminfo.state != VMInfoState.ATTACHED) {
				System.out.println("\nERROR: Could not attach to process, please find reason in README\n");
				return;
			}

			// 3. create view
			VMDetailView.DetailMode displayMode = parseDisplayMode(optionSet);
			Integer width = null;
			if (optionSet.hasArgument("width")) {
				width = (Integer) optionSet.valueOf("width");
			}

			VMDetailView view = new VMDetailView(vminfo, displayMode, width);

			if (optionSet.hasArgument("limit")) {
				Integer limit = (Integer) optionSet.valueOf("limit");
				view.threadLimit = limit;
			}

			// 4. create main application
			VJTop app = new VJTop();
			app.mainThread = Thread.currentThread();
			app.view = view;

			Integer interval = DEFAULT_INTERVAL;
			if (optionSet.hasArgument("interval")) {
				interval = (Integer) (optionSet.valueOf("interval"));
				if (interval < 1) {
					throw new IllegalArgumentException("Interval cannot be set below 1.0");
				}
			}
			app.interval = interval;

			if (optionSet.hasArgument("n")) {
				Integer iterations = (Integer) optionSet.valueOf("n");
				app.maxIterations = iterations;
			}

			// 5. start thread to get user input
			Thread interactiveThread = new Thread(new InteractiveTask(app), "InteractiveThread");
			interactiveThread.setDaemon(true);
			interactiveThread.start();

			// 6. run app
			app.run(view);
		} catch (Exception e) {
			e.printStackTrace(System.out);
			System.out.flush();
		}
	} 
                            #location 56 
                            #vulnerability type RESOURCE_LEAK