Comments (11)
Hi @blowekamp.
I removed JAVAFX, and did some tests and found the source of the problem is this line: byte[] oldPixels = volumeToByteArray(tempImage);
private byte[] volumeToByteArray (Image image) {
ByteBuffer imageDataBuffer = image.getBufferAsByteBuffer();
byte[] imageByteArray = new byte[imageDataBuffer.remaining()];
imageDataBuffer.get(imageByteArray);
return imageByteArray;
}
it is possible to reproduce without JAVAFX.
from simpleitk.
Thank you for the bug report. Are you able to reproduce the issue with out javafx?
from simpleitk.
It seems that there is a residue generated at the beginning of the first 510/520 images.
I implemented a max/min ms count.
this is the slow point where it starts to get super slow
then after it reaches the peak of slowness, i run GC manually from JProfiler (there is a button for this).
The ms drops instantly .
After rendering a long time, remains stable.
from simpleitk.
I'm not a Java person, but could you force the garbage collector to run every time?
from simpleitk.
yes you could call GC anytime with System.gc()
, i made a temporary solution for me that runs in a thread.
private void gcThread () {
int minIntendedFPS = 20;
long minIntendedRenderTime = 1000/minIntendedFPS;
try {
while (true) {
if (this.renderTime > minIntendedRenderTime) {
System.out.println("performing GC");
System.gc();
Thread.sleep(500);
}
Thread.sleep(100);
}
} catch (Exception e) {
e.printStackTrace();
}
}
from simpleitk.
I'm not a Java person, but could you force the garbage collector to run every time?
I don' think that should be needed.?
Here is the wrapping code related to getting the buffer in JAVA. Maybe you can gain some insight or see a way to improve the code:
SimpleITK/Wrapping/Java/Java.i
Lines 37 to 109 in 46bf97c
from simpleitk.
I thought in the past the issue with Java was that you'd delete objects, but then the garbage collector wouldn't kick in til later. It would be doing memory management on a bunch of deleted objects all at once, leading to very uneven performance for real-time sort of applications.
from simpleitk.
Hi @dave3d and @blowekamp,
in fact all simpleitk filters become slow over time, some more than others. I found that setting setNumberOfWorkUnits(1) for the filters makes them massively speed up and never slow down. So default workUnits is causing problems, and since there is almost no documentation for Java...
from simpleitk.
6 months ago I was also having a problem related to performance with ImageSeriesReader, I reported it on itk.org but we were unable to reach any conclusion, it is likely that the case now has some relation?
https://discourse.itk.org/t/simpleitk-incremental-loading-java/6089/9?u=salu_ramos
from simpleitk.
in fact all simpleitk filters become slow over time, some more than others. I found that setting setNumberOfWorkUnits(1) for the filters makes them massively speed up and never slow down. So default workUnits is causing problems, and since there is almost no documentation for Java...
For these other filter, Is there a slow down if you are only using SimpleITK code and not doing buffer access? If so that points more to memory management (or threading) issues in the JAVA and the JNI.
You can find SimpleITK documentation on SetNumberOfWorkUnits here. The concepts of ITK threading should be converted in the ITK documentation ( but I can't find a good link right now).
from simpleitk.
For these other filter, Is there a slow down if you are only using SimpleITK code and not doing buffer access?
yes.
from simpleitk.
Related Issues (20)
- missing numpy dependency in python wheels and conda package HOT 2
- Move detailed class description to the top of the doc page
- Install on IpadOS v16.6 HOT 2
- RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: ../Code/IO/src/sitkImageReaderBase.cxx:97: sitk::ERROR: HOT 1
- Add ImageSeriesReader::SpacingWarningRelThreshold
- enable ImageFileReader.SetUseStreaming method for JAVA
- SetKernelRadius() does not handle numpy integer types HOT 1
- Extend sitk.ReadImage()/WriteImage() to support pathlib.Path() HOT 1
- add or change the interface for the ImageRegistraitonMethod.SetOptimizerAsAmoeba method HOT 1
- Error writing `SimpleITK Image` to DICOM files
- GetBufferAsType functions missing (Python 3.12.1, SimpleITK 2.3.1) HOT 8
- PEP 688 add buffer protocol support
- After registration, is the order of transforms composition specified in the documentation correct? HOT 4
- `MetaData dictionary key must be str`? HOT 2
- simpleITK python acts differently while reading metadata with upper or lower case hexadecimal label HOT 5
- Figure illustrating image concepts doesn't have clear text HOT 5
- ThresholdImage filter in Python HOT 2
- Add way to search docs
- Add docs on how to set/get the mask on an image HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleitk.