|
From: Matthieu C. <cho...@gm...> - 2008-08-29 20:35:16
|
Hi, I'm not at homeand cannot test your patch but it could be and idea to test, a better solution would be to add an option (maybe in Debug class), se we can enable and disableit easily and it will be easy to do comparison. would it be possible thanks Matthieu On Fri, Aug 29, 2008 at 12:39 AM, Kazutoshi Satoda <k_s...@f2...> wrote: > Hi, > > I have been playing memory hunting in jEdit for these days. > > jProfiler shows that one of the biggest memory consumer in jEdit is > FastRepaintManager. The amount of consumed memory depends on the area of > TextArea; about 4 MB in my usual use ~ 8 MB in maximized window. And it > is reallocated every time the TextArea is resized (resizing the View, or > activating or deactivating dockables). If I maximize the View, the > consumption climbs up to 12 MB until the old one is GCed. > > I have tried to disabling FastRepaintManager, and done it. The effect in > memory is what I expected, it is quite low and stable. > > Also, I expected some slow down because FastRepaintManager is clearly > for speed. But surprisingly, I can't see any slow down. > > Another good of disabling FastRepaintManager is that the Background > plugin is back to work. See the following bug. > "Background Plugin - Scrolling with MouseWheel Issue" > https://sourceforge.net/support/tracker.php?aid=1620694 > > While having tested for a few days, I have almost concluded to drop > FastRepaintManager for memory use and Background plugin. If someone know > how FastRepaintManager really benefits, please let me know. Without some > evidence, I'll commit the attached patch in a few days and start soaking > for the next release. > > -- > k_satoda > > Index: org/gjt/sp/jedit/textarea/BufferHandler.java > =================================================================== > --- org/gjt/sp/jedit/textarea/BufferHandler.java (revision 13446) > +++ org/gjt/sp/jedit/textarea/BufferHandler.java (working copy) > @@ -424,7 +424,6 @@ > private void delayUpdate(int startLine, int endLine) > { > textArea.chunkCache.invalidateChunksFromPhys(startLine); > - textArea.repaintMgr.setFastScroll(false); > > if(!delayedUpdate) > { > Index: org/gjt/sp/jedit/textarea/TextAreaPainter.java > =================================================================== > --- org/gjt/sp/jedit/textarea/TextAreaPainter.java (revision 13446) > +++ org/gjt/sp/jedit/textarea/TextAreaPainter.java (working copy) > @@ -169,8 +169,6 @@ > textArea.propertiesChanged(); > textArea.updateMaxHorizontalScrollWidth(); > textArea.scrollBarsInitialized = true; > - > - textArea.repaintMgr.updateGraphics(); > } //}}} > > //{{{ getFocusTraversalKeysEnabled() method > @@ -728,48 +726,35 @@ > @Override > public void paint(Graphics _gfx) > { > - Graphics2D gfx = textArea.repaintMgr.getGraphics(); > - > + assert(_gfx instanceof Graphics2D); > + Graphics2D gfx = (Graphics2D)_gfx; > gfx.setRenderingHints(renderingHints); > fontRenderContext = gfx.getFontRenderContext(); > > - Rectangle clipRect = _gfx.getClipBounds(); > - > - JEditBuffer buffer = textArea.getBuffer(); > + Rectangle clipRect = gfx.getClipBounds(); > int lineHeight = fm.getHeight(); > - if(lineHeight == 0 || buffer.isLoading()) > + if(lineHeight == 0 || textArea.getBuffer().isLoading()) > { > - _gfx.setColor(getBackground()); > - > _gfx.fillRect(clipRect.x,clipRect.y,clipRect.width,clipRect.height); > + gfx.setColor(getBackground()); > + > gfx.fillRect(clipRect.x,clipRect.y,clipRect.width,clipRect.height); > } > else > { > - long prepareTime = System.currentTimeMillis(); > - FastRepaintManager.RepaintLines lines > - = > textArea.repaintMgr.prepareGraphics(clipRect, > - textArea.getFirstLine(),gfx); > - prepareTime = (System.currentTimeMillis() - > prepareTime); > + // Because the clipRect's height is usually an even > multiple > + // of the font height, we subtract 1 from it, > otherwise one > + // too many lines will always be painted. > + int firstLine = clipRect.y / lineHeight; > + int lastLine = (clipRect.y + clipRect.height - 1) / > lineHeight; > > - long linesTime = System.currentTimeMillis(); > - int numLines = (lines.last - lines.first + 1); > + int numLines = (lastLine - firstLine + 1); > + int y = firstLine * lineHeight; > > - int y = lines.first * lineHeight; > + gfx.setColor(getBackground()); > gfx.fillRect(0,y,getWidth(),numLines * lineHeight); > > + gfx.setFont(getFont()); > extensionMgr.paintScreenLineRange(textArea,gfx, > - lines.first,lines.last,y,lineHeight); > - linesTime = (System.currentTimeMillis() - > linesTime); > - > - textArea.repaintMgr.setFastScroll( > - clipRect.equals(new Rectangle(0,0, > - getWidth(),getHeight()))); > - > - long blitTime = System.currentTimeMillis(); > - textArea.repaintMgr.paint(_gfx); > - blitTime = (System.currentTimeMillis() - blitTime); > - > - if(Debug.PAINT_TIMER && numLines >= 1) > - Log.log(Log.DEBUG,this,"repainting " + > numLines + " lines took " + prepareTime + "/" + linesTime + "/" + blitTime + > " ms"); > + firstLine,lastLine,y,lineHeight); > } > > textArea.updateMaxHorizontalScrollWidth(); > Index: org/gjt/sp/jedit/textarea/TextArea.java > =================================================================== > --- org/gjt/sp/jedit/textarea/TextArea.java (revision 13446) > +++ org/gjt/sp/jedit/textarea/TextArea.java (working copy) > @@ -268,7 +268,6 @@ > selectionManager = new SelectionManager(this); > chunkCache = new ChunkCache(this); > painter = new TextAreaPainter(this); > - repaintMgr = new FastRepaintManager(this,painter); > gutter = new Gutter(this); > gutter.setMouseActionsProvider(new > MouseActions(propertyManager, "gutter")); > listenerList = new EventListenerList(); > @@ -544,7 +543,6 @@ > this.buffer.beginCompoundEdit(); > > chunkCache.setBuffer(buffer); > - repaintMgr.setFastScroll(false); > propertiesChanged(); > > if(displayManager != null) > @@ -4795,7 +4793,6 @@ > displayManager.notifyScreenLineChanges(); > } > > - repaintMgr.setFastScroll(false); > chunkCache.invalidateAll(); > gutter.repaint(); > painter.repaint(); > @@ -4860,7 +4857,6 @@ > final Segment lineSegment = new Segment(); > MouseInputAdapter mouseHandler; > final ChunkCache chunkCache; > - final FastRepaintManager repaintMgr; > DisplayManager displayManager; > final SelectionManager selectionManager; > /** > @@ -4974,7 +4970,6 @@ > //{{{ foldStructureChanged() method > void foldStructureChanged() > { > - repaintMgr.setFastScroll(false); > chunkCache.invalidateAll(); > recalculateLastPhysicalLine(); > repaint(); > @@ -5225,8 +5220,6 @@ > if(!buffer.isTransactionInProgress()) > _finishCaretUpdate(); > /* otherwise DisplayManager.BufferChangeHandler calls */ > - > - repaintMgr.setFastScroll(false); > } //}}} > > //{{{ fireCaretEvent() method > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > -- > ----------------------------------------------- > jEdit Developers' List > jEd...@li... > https://lists.sourceforge.net/lists/listinfo/jedit-devel > > |