Home > Back-end >  Java ImageIO. Read image processing
Java ImageIO. Read image processing

Time:10-31

In use ImageIO. Read image processing, going up all the sensory memory, always can't release

 
@ RequestMapping (value="https://bbs.csdn.net/test")
@ ResponseBody
Public Result FaceAdd () {
Try {
The File f=new File (" C: \ \ Users \ \ Administrator \ \ Desktop \ \ 1. PNG ");
Try {
ImageInfo ImageInfo=ImageUtil. GetRGBData (f);
Logger. The info (" recognition: "+ f.g etName ());
} the catch (Exception e) {
Logger. The error (" recognition: "+ f.g etName () +" failure ");
}
Return the newSuccessResult (" ");
} the catch (Exception e) {
Logger. The error (" ", e);
} the finally {
}
Return the newFailedResult (ErrorCodeEnum. UNKNOWN);
}

 public static ImageInfo getRGBData (File File) {
If (the file==null)
return null;
ImageInfo ImageInfo;
Try {
//the image file is loaded into the memory buffer
BufferedImage image=ImageIO. Read (file);
Image. The flush ();
} the catch (IOException e) {
e.printStackTrace();
return null;
}
return null;
}



A pure spring boot project has just started probably take up from 200 M in, cycle after 1000 times the method, G, then rose
Hope leaders help me

CodePudding user response:

Top post

CodePudding user response:

The dispose ()

CodePudding user response:

Tried, useless,

CodePudding user response:

Look not to come out first what you returned, ImageInfo this entity class, exactly have included the whole picture of byte [] data, or only contains some aspect, the File path information, if you include the whole image, then check this method outer layer, the caller to the object returned to deposit in any list,
If not included, so you changed to:
FileInputStream fis=null;
Try {
Fis=new FileInputStream (f);
ImageIO. Read (fis);
} the catch (Exception e) {
throw e;
} the finally {
CloseUtil. Close (fis);
}


The CloseUtil. Close (fis) methods:
Public class CloseUtil {
Public static void close (Closeable... Closeables) {
If (closeables==null) {
return;
}
For (Closeable Closeable: closeables) {
If (closeable!=null) {
Try {
Closeable. Close ();
} the catch (IOException e) {
}
}
}
}
}

The flow off clean, release the documents,
  • Related