Note that there are some explanatory texts on larger screens.

plurals
  1. POC# What's up with font.DrawText
    primarykey
    data
    text
    <p>I was testing a DX scrolling banner that I've recently completed. The problem is that it's consuming very large amounts of memory.</p> <p>The string to be scrolled is created using an array of characters and their sizes (using DX measure string) created from the source string (rss feed) and stored in an array. The rss feed, in this case, was about 500 characters long.</p> <p>To create the scrolled string, I simply add/remove characters as the come into/outof view (using panel width &amp; character sizes to determine the time to add/remove characters from the string) on the display panel. It works very well but is using 200M of memory. The string is never more that about 80 characters long (I've made sure of this by using an alert if it exceeds 80 chars). The amount of characters in the string is dependant, of course, on the size of the font.</p> <p>If I comment out the DrawText command, the app uses little memory (proving that it's not some other part of the code). If I just scroll the entire string (500 chars) the memory used is only 32M. However, I'm now using lots of Proc scrolling such a large string.</p> <p>I've noticed that when you draw a static (not scrolling) large string and then follow it with, say, a single character string, DrawText does not free the memory used to draw the large string. I'm using theString.Remove &amp; theString.Insert to create the string to be scrolled. The memory seems to crawls up as each character is Added/Subtracted and once the entire RSS feed string has been scrolled, the memory usage stays static - at 200M - from then on in.</p> <p>What's going on? Any help very much appreciated... it's driving me nuts! I could just split the feed into strings but it makes more sense to do it character by character.</p> <pre><code> private void sync() { if (device.RasterStatus.ScanLine) { UpdateDisp(); if (ArStringSegments.Count != 0) { for (int i = 0; i != Speed; i++) { # region Add a character to the displayed string if (FirstCharLength == 0 &amp;&amp; AddChrIndex != ArStringSegments.Count) { StringProps StringProps = (StringProps)ArStringSegments[AddChrIndex]; if (ScrollDirection == Direction.ToLeft) { theString = theString.Insert(theString.Length, StringProps.String); } AddChrIndex++; } # endregion Add a character to the string # region remove a character from the string as it goes beyond the veiwable area if (RemoveChrIndex != ArStringSegments.Count) { if (ScrollDirection == Direction.ToLeft) { if(ScrollInc == 0 - LargestChar) { StringProps RemoveString = (StringProps)ArStringSegments[RemoveChrIndex]; theString = theString.Remove(0, 1); ScrollInc += RemoveString.Size1; RemoveChrIndex++; } } } # endregion remove a character from the string as it goes beyond the veiwable area # region Increment/decrement position if (ScrollDirection == Direction.ToLeft) { ScrollInc--; FirstCharLength--; } # endregion Increment/decrement position # region Entire string has gone out of viewable area, scroll out by an amount and then start again. if ((ScrollInc == 0 - (ScrollOutLength + LargestChar ) &amp;&amp; ScrollDirection == Direction.ToLeft) || (ScrollInc == PanWidth + (ScrollOutLength + LargestChar) &amp;&amp; ScrollDirection == Direction.ToRight)) { theString = ""; AddChrIndex = 0; RemoveChrIndex = 0; FirstCharLength = 0; if (ScrollDirection == Direction.ToLeft) { ScrollInc = this.PanWidth; } else { ScrollInc = 0; RightBoundary = 0; } } # endregion entire string has gone out of viewable area, scroll out by an amount and then start again. } } } ScanCount = device.RasterStatus.ScanLine; } private void UpdateDisp() { try { if (device.CheckCooperativeLevel(out DeviceStatus)) { if (UpdateDisplayEnabled == true) { device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0); device.BeginScene(); // background image Texture BackSprite = new Sprite(device); BackSprite.Begin(SpriteFlags.AlphaBlend); BackSprite.Draw2D(PanelTexture, new Point(0, 0), 0.0F, new Point(0, 0), Color.White); BackSprite.End(); BackSprite.Dispose(); // draw the text Draw2DText(FeedText[i], ScrollInc, 0, FontColor); font.DrawText(null, theString, new Rectangle(ScrollInc, 0, device.EndScene(); if (device.CheckCooperativeLevel(out DeviceStatus)) device.Present((IntPtr)DxRenderPanel); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload