<html><body>
<p><font size="2" face="sans-serif">Hi Everyone,</font><br>
<br>
<font size="2" face="sans-serif">One of my programs has a 'terminal' where incoming text is shown. I've done this by writing text to a graphics figure. The text is stored as a global vector ('displaytext') consisting of lines (strings) which are written to the figure by means of the handle to the text entity (texthdl.text = displaytext). The code for this is shown below.</font><br>
<font size="2" face="sans-serif">The display is updated around four times per second.</font><br>
<font size="2" face="sans-serif">Notice also an eventhandler in the figure, which allows the looping which generates the text to be stopped.</font><br>
<br>
<font size="2" face="sans-serif">All too often SciLab crashes and the error messages which appear in the console are shown below.</font><br>
<br>
<font size="2" face="sans-serif">I've tried to work around this by closing and re-opening the figure after #disptot lines have been written - this is the purpose of variables 'disptot' and 'restart'. However, #disptot can be quite low, 40 say, and SciLab will still crash.</font><br>
<font size="2" face="sans-serif">It looks to me like memory is not being freed after use and so runs out. I haven't been able to work out whether it's the number of lines or the number of characters which determines how soon it crashes.</font><br>
<br>
<font size="2" face="sans-serif">Any suggestions ?</font><br>
<font size="2" face="sans-serif">This looks like a bug to me. Are there any fixes ?</font><br>
<br>
<font size="2" face="sans-serif">Alternatively, if I knew what made it crash I might be able to make the software adaptive so it only re-opens the figure as infrequently as necessary - re-opening the figure is slightly annoying, having to continually close and re-launch SciLab is a real pain.</font><br>
<br>
<font size="2" face="sans-serif">I'm using SciLab 5.4.0 in Windows XP SP3 32 bit.</font><br>
<br>
<font size="2" face="sans-serif">Many thanks in anticipation,</font><br>
<br>
<font size="2" face="sans-serif">Adrian.</font><br>
<br>
<br>
<br>
<br>
<font size="2" face="sans-serif">#ldisplay = 50</font><br>
<font size="2" face="sans-serif">#disptot = 100</font><br>
<br>
<font size="2" face="sans-serif">function </font><font size="2" face="sans-serif"><u>StartDisplay</u></font><font size="2" face="sans-serif">(restart)<br>
<br>
global figrhdl;<br>
global texthdl;<br>
global displaytext;<br>
global disptot;<br>
global stophdl;<br>
<br>
disptot = 0;<br>
<br>
figrhdl = </font><font size="2" face="sans-serif"><u>scf</u></font><font size="2" face="sans-serif">(1);<br>
figrhdl.figure_position = [#fig1_xTLC, #fig1_yTLC];<br>
figrhdl.figure_size = [#fig1_width, #fig1_height];<br>
figrhdl.figure_name = "Message window.";<br>
<br>
xstring(-0.1,1.1,"LEFT CLICK HERE TO STOP LOOPING");<br>
stophdl = </font><font size="2" face="sans-serif"><u>gce</u></font><font size="2" face="sans-serif">();<br>
stophdl.font_style = 0;<br>
stophdl.font_size = 2;<br>
stophdl.box = 'on';<br>
<br>
</font><font size="2" face="sans-serif"><u>seteventhandler</u></font><font size="2" face="sans-serif">('StopLoop');<br>
figrhdl.event_handler = 'StopLoop';<br>
figrhdl.event_handler_enable = 'on';<br>
<br>
if ~restart then // if restart = %t the displaytext is not cleared<br>
displaytext(1: #ldisplay) = " ";<br>
end<br>
<br>
xstring(-0.1, -0.1, displaytext); // this writes the text initially<br>
texthdl = gce();<br>
texthdl.font_style = 0;<br>
texthdl.font_size = 2;<br>
<br>
endfunction<br>
<br>
function DisplayText(textlines, clrfirst)<br>
<br>
global figrhdl;<br>
global texthdl;<br>
global displaytext;<br>
global disptot;<br>
<br>
if clrfirst then displaytext(1: #ldisplay) = " "; end // if clrfirst = %t then displaytext is cleared<br>
<br>
nlines = size(textlines, 'r'); // these lines, from here<br>
offset = #ldisplay - nlines;<br>
<br>
if nlines < #ldisplay then<br>
i = 1: offset;<br>
displaytext(i) = displaytext(i + nlines);<br>
<br>
i = 1: nlines;<br>
displaytext(offset + i) = textlines(i) + ' ';<br>
else<br>
i = 1: #ldisplay;<br>
displaytext(i) = textlines(i - offset) + ' ';<br>
end // to here update displaytext by replacing lines with the new 'textlines'<br>
<br>
if disptot >= #disptot then // if disptot lines have been written the figure is closed and re-opened<br>
</font><font size="2" face="sans-serif"><u>close</u></font><font size="2" face="sans-serif">(figrhdl);<br>
</font><font size="2" face="sans-serif"><u>StartDisplay</u></font><font size="2" face="sans-serif">(%t);<br>
end<br>
<br>
texthdl.text = displaytext; // this writes the text to the figure<br>
disptot = disptot + 1;<br>
<br>
endfunction</font><br>
<br>
<br>
<br>
<br>
<font size="2" face="sans-serif">Exception in thread "Thread-1782" javax.media.opengl.GLException: java.lang.reflect.InvocationTargetException</font><br>
<font size="2" face="sans-serif"> at javax.media.opengl.awt.GLJPanel.display(GLJPanel.java:265)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.JoGLCanvas$CanvasAnimator.run(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.lang.Thread.run(Unknown Source)</font><br>
<font size="2" face="sans-serif">Caused by: java.lang.reflect.InvocationTargetException</font><br>
<font size="2" face="sans-serif"> at java.awt.EventQueue.invokeAndWait(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at javax.media.opengl.awt.GLJPanel.display(GLJPanel.java:263)</font><br>
<font size="2" face="sans-serif"> ... 2 more</font><br>
<font size="2" face="sans-serif">Caused by: java.lang.OutOfMemoryError: Java heap space</font><br>
<font size="2" face="sans-serif"> at java.awt.image.DataBufferInt.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.awt.image.Raster.createPackedRaster(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.awt.image.BufferedImage.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.TextureBufferedImage.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.BufferedImageTextureDrawingTools.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.DrawnTextureDataProvider.reDraw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.DrawnTextureDataProvider.getImage(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.DrawnTextureDataProvider.getSubImage(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager$JoGLTexture.checkData(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager$JoGLTexture.preDraw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.JoGLDrawingTools.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.text.TextManager.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.graphic_objects.textObject.Text.accept(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.axes.AxesDrawer.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.graphic_objects.axes.Axes.accept(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.graphic_objects.figure.Figure.accept(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.JoGLCanvas.display(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)</font><br>
<font size="2" face="sans-serif"> at javax.media.opengl.awt.GLJPanel$Updater.display(GLJPanel.java:655)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLPbufferImpl$DisplayAction.run(GLPbufferImpl.java:300)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)</font><br>
<font size="2" face="sans-serif">Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space</font><br>
<font size="2" face="sans-serif"> at java.awt.image.DataBufferInt.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.awt.image.Raster.createPackedRaster(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at java.awt.image.BufferedImage.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.TextureBufferedImage.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.BufferedImageTextureDrawingTools.<init>(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.DrawnTextureDataProvider.reDraw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.DrawnTextureDataProvider.getImage(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.texture.DrawnTextureDataProvider.getSubImage(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager$JoGLTexture.checkData(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager$JoGLTexture.preDraw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.JoGLDrawingTools.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.text.TextManager.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.graphic_objects.textObject.Text.accept(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.axes.AxesDrawer.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.graphic_objects.axes.Axes.accept(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.graphic_objects.figure.Figure.accept(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.modules.renderer.JoGLView.DrawerVisitor.draw(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at org.scilab.forge.scirenderer.implementation.jogl.JoGLCanvas.display(Unknown Source)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)</font><br>
<font size="2" face="sans-serif"> at javax.media.opengl.awt.GLJPanel$Updater.display(GLJPanel.java:655)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLPbufferImpl$DisplayAction.run(GLPbufferImpl.java:300)</font><br>
<font size="2" face="sans-serif"> at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)</font><br>
<font size="2" face="sans-serif"><br>
</font><br>
<br>
<font size="2" face="sans-serif"><br>
</font>
<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td class="t" width="178" valign="middle">
<ul style="padding-left: 1pt"><font size="2" color="#333333" face="Arial"><b>Adrian Weeks </b></font><font size="1" color="#666666" face="Arial"><br>
Development Engineer <br>
<br>
<br>
HID Global,<br>
3 Cae Gwyrdd,<br>
Green Meadow Springs<br>
Business Park,<br>
Cardiff CF15 7AB,<br>
United Kingdom.<br>
+44 (0)29 20528523 (Office)</font><font size="1" color="#0000FF" face="Arial"><u><br>
</u></font><a href="mailto:aweeks@hidglobal.com"><font size="1" color="#0000FF" face="Arial"><u>aweeks@hidglobal.com</u></font></a><font size="1" color="#0000FF" face="Arial"><u><br>
</u></font><a href="http://www.hidglobal.com/"><font size="1" color="#0000FF" face="Arial"><u>www.hidglobal.com</u></font></a></ul>
</td><td width="139" valign="middle">
<ul style="padding-left: 1pt"><a href="http://www.hidglobal.com/"><img src="cid:1__=0FBBF665DFA484798f9e8a93df93869@prox.com" width="130" height="170" border="0"></a></ul>
</td></tr>
</table>
<br>
</body></html>