Skip to content

Instantly share code, notes, and snippets.

View hinerm's full-sized avatar

Mark Hiner hinerm

View GitHub Profile
2023-03-24 11:22:00
Full thread dump OpenJDK 64-Bit Server VM (25.332-b09 mixed mode):
"RMI TCP Connection(2)-192.168.68.53" #66 daemon prio=5 os_prio=0 tid=0x00000173573c2800 nid=0x55a8 runnable [0x000000648192d000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
@hinerm
hinerm / ij_test.py
Created April 19, 2021 18:14
A trivial python script that takes an input image and outputs a "copy", with all values set to the first pixel value.
#@ OpService ops
#@ ImgPlus image
#@OUTPUT ImgPlus copy
#@OUTPUT Integer a
a = 21
copy = ops.copy().img(image.getImg())
c = copy.cursor()
c.fwd()
v = c.get().copy()
@hinerm
hinerm / Regex.java
Created January 25, 2018 15:45
Regex fun
package test;
import java.util.StringJoiner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Sandbox {
@hinerm
hinerm / Regex.java
Created January 25, 2018 15:45
Regex fun
package test;
import java.util.StringJoiner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Sandbox {
@hinerm
hinerm / Leak.txt
Last active December 8, 2015 15:05
Python memory leak
The following images show memory leaks due to mapped images not being cleaned up.
The MemoryOverview shows two hard reference paths keeping byte[] instances alive (blue and green). They both go through python classes to a HashMap.
The Objects1 and Objects2 images show these two paths expanded and reveals that we likely have two paths to the same map, and thus to the same set of objects.
Persumably our Python code is making these mappings but not cleaning up after them. Persumably there is also a hard reference to these images in ImageJ itself, so it would make sense on the Python side to cache WeakReferences to the images - or add some callback that ensures these mappings are eventually removed (or manually clean the maps at the end of the script).
To find the problematic python code we can look for the relevant variable names (snapshotPixels, rLUT1, bLUT1, gLUT1, etc...)
@hinerm
hinerm / soapes.ijm
Last active November 12, 2015 14:53
IJ skeleton/foci analysis
// search for TODO sections to see parameters that still need tuning
//This macro takes a 3-channel 16 bit immunofluorescance image as input.
// channel 1 (red): SC
// channel 2 (green): foci
// channel 3 (blue): centromeres
//The primary goal of this macro is to identify rois covering main cell features,
//measure the total distance of skeletonized SC, number of foci on each SC and distance from foci to the centromere on the same skeleton
// Requirements:
@hinerm
hinerm / Main.java
Created June 18, 2015 18:14
Test the ability of a jar to overwrite itself
package org.scijava;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String... args) throws IOException {
//FIXME: set this path to the location of the jar containing this main class.
String url = "C:/Users/Johannes/loci/test/target/scijava-tests-2.43.1-SNAPSHOT.jar";
@hinerm
hinerm / Main.java
Created June 18, 2015 17:50
Test for URLClassLoader.close
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
public class Main {
<?xml version="1.0" encoding="UTF-8"?>
<?JvmMonitor version="3.8.1"?>
<cpu-profile date="2015/01/25 12:09:02" runtime="8608@localhost" mainClass="org.eclipse.jdt.internal.junit.runner.RemoteTestRunner" arguments="-Dscijava.log.level=error -Dfile.encoding=UTF-8">
<thread name="main">
<frame name="io.scif.services.SCIFIODatasetService.create(net.imagej.ImgPlus)" cnt="1" time="0">
<frame name="io.scif.services.SCIFIODatasetService.datasetService()" cnt="1" time="0"/>
</frame>
<frame name="io.scif.services.DefaultDatasetIOService.open(java.lang.String)" cnt="7676" time="175061">
<frame name="io.scif.config.SCIFIOConfig.imgOpenerSetIndex(int)" cnt="7676" time="0">
<frame name="io.scif.config.SCIFIOConfig.imgOpenerSetRange(io.scif.img.Range)" cnt="7676" time="0"/>