Skip to content

Commit

Permalink
issue #11: java.lang.OutOfMemoryError when activating ShowEditorOnlyA…
Browse files Browse the repository at this point in the history
…ction: add some logging and changed width calculation logic
  • Loading branch information
markiewb committed Feb 5, 2015
1 parent f823fb4 commit 37ee6d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.markiewb.netbeans.plugins</groupId>
<artifactId>codeoutline</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
<packaging>nbm</packaging>
<build>
<plugins>
Expand Down Expand Up @@ -87,6 +87,8 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.run.params.ide/>
<netbeans.run.params>-J-javaagent:"${current.jrebel.agent.path}" -J-Drebel.log=true ${netbeans.run.params.ide}</netbeans.run.params>
</properties>
<name>Code outline</name>
<description>This plugins adds a code overview/outline for the current editor.
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/bluej/editor/moe/NaviView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ of the License, or (at your option) any later version.
import javax.swing.text.Position.Bias;

import bluej.Config;
import java.util.logging.Logger;
//import bluej.parser.nodes.ParsedNode;
//import bluej.parser.nodes.NodeTree.NodeAndPosition;

Expand Down Expand Up @@ -357,7 +358,8 @@ private void paintImgBuffer(int top, int bottom)

if (prefViewHeight > myHeight) {
// scale!
int width = Math.max(imgBuffer.getWidth() * prefViewHeight / myHeight, 1);
//potential bugfix: https://github.com/markiewb/nb-codeoutline/issues/11
int width = Math.min(imgBuffer.getWidth() * prefViewHeight / myHeight, 400);
int ytop = top * prefViewHeight / myHeight;
int ybtm = (bottom * prefViewHeight + myHeight - 1) / myHeight;
int height = ybtm - ytop;
Expand All @@ -381,6 +383,7 @@ private void paintImgBuffer(int top, int bottom)
bottom = top + (height * myHeight / prefViewHeight);
}

Logger.getLogger("NaviView").info(String.format("Tried to create an image %s x %s top=%s, bottom=%s, myHeight=%s, ytop=%s,ybtm=%s, which may lead to an OOME.", width, height, top, bottom, myHeight, ytop,ybtm));
// Create a buffered image to use
BufferedImage bimage = g.getDeviceConfiguration().createCompatibleImage(width, height,Transparency.TRANSLUCENT);
Map<Object,Object> hints = new HashMap<Object,Object>();
Expand Down Expand Up @@ -581,7 +584,8 @@ public void createImgBuffer(Graphics g, boolean scaling)
return;
}
}

// Logger.getLogger("NaviView").severe(String.format("image buffer %sx%s %sx%s", w,h, getWidth(), getHeight()));

BufferedImage oldImgBuffer = imgBuffer;

if (g instanceof Graphics2D) {
Expand Down

0 comments on commit 37ee6d6

Please sign in to comment.