PC Review


Reply
Thread Tools Rate Thread

CE.Net 4.1 performance

 
 
=?Utf-8?B?UmljaGFyZCBKb25lcw==?=
Guest
Posts: n/a
 
      16th Feb 2004
When I run my application (which continuously monitors the serial port) it slows every 30 seconds or so, often pausing for about a second. It shouldn't do this! It's written in VB.Net and uses the .NET CF

It appears to me that there are other services running in the background. Anyone got any advice how I can find out what these are and how I can stop them? Or does anyone have any other ideas what this strange effect is? I can slightly improve matters by setting the thread priority to 'highest' but it doesn't solve the problem completely

Richar


 
Reply With Quote
 
 
 
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      16th Feb 2004
You might be running into an issue of garbage collector making a pass. Do
you create a lot of short-lived objects? Example is a polling loop with
local variable(s) defined inside. If this is the case, consider defining the
variable outside the loop

"Richard Jones" <(E-Mail Removed)> wrote in message
news:6A1D4520-5F22-45BD-8DCB-(E-Mail Removed)...
> When I run my application (which continuously monitors the serial port) it

slows every 30 seconds or so, often pausing for about a second. It shouldn't
do this! It's written in VB.Net and uses the .NET CF.
>
> It appears to me that there are other services running in the background.

Anyone got any advice how I can find out what these are and how I can stop
them? Or does anyone have any other ideas what this strange effect is? I can
slightly improve matters by setting the thread priority to 'highest' but it
doesn't solve the problem completely.
>
> Richard
>
>



 
Reply With Quote
 
=?Utf-8?B?UmljaGFyZCBKb25lcw==?=
Guest
Posts: n/a
 
      17th Feb 2004
Thanks Alex. I'm going to re-define all the local variables as globals and see what happens.
 
Reply With Quote
 
=?Utf-8?B?UmljaGFyZCBKb25lcw==?=
Guest
Posts: n/a
 
      17th Feb 2004
Actually I think I may have found the source of the problem - I have a draw text routine (can't use labels, too many of them!), which is called repeatedly. The code creates lots of local objects and is awash with 'New' statements - it's below. Could anyone give me some pointers as to the best way to correct this to cope with the Garbage Collector? The passed variables pointx, pointy, sizex, sizey and drawtext change obviously

Any help appreciated
And

Public Sub direct_draw_text_small(ByVal text_col As Color, ByVal pointx As Integer, ByVal pointy As Integer, ByVal sizex As Integer, ByVal sizey As Integer, ByVal drawtext As String

' draw text using direct draw technique (called directly from main thread
Dim r As New RectangleF(pointx, pointy, sizex, sizey
Dim rr As New RectangleF(0, 0, sizex, sizey
Dim b As New SolidBrush(text_col

bufferbmp = New Bitmap(sizex, sizey

' to avoid flicker, double buffer onto bitmap then display
Dim gxOff As Graphics = Graphics.FromImage(bufferbmp
gxOff.DrawString(drawtext, glf_font11tahoma, b, rr
gxOff.Dispose(

' dra
Dim gxOn As Graphics = Me.CreateGraphics(
gxOn.DrawImage(bufferbmp, pointx, pointy
gxOn.Dispose(

' manually release graphics objects
b.Dispose(
bufferbmp.Dispose(

End Su

 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      19th Feb 2004
A lot of this stuff can be moved outside of this function. You can use a
single, screen-sized bitmap for all your offscreen drawing and keep the
Graphics object associated with it alive at all times. Same goes for
rectangles and brushes. The easiest way would be to create a class for
drawing the text and move all these objects into the member variables
(perhaps static).

"Richard Jones" <(E-Mail Removed)> wrote in message
news:7D71BABA-A863-45B2-BFB3-(E-Mail Removed)...
> Actually I think I may have found the source of the problem - I have a

draw text routine (can't use labels, too many of them!), which is called
repeatedly. The code creates lots of local objects and is awash with 'New'
statements - it's below. Could anyone give me some pointers as to the best
way to correct this to cope with the Garbage Collector? The passed variables
pointx, pointy, sizex, sizey and drawtext change obviously.
>
> Any help appreciated!
> Andy
>
>
> Public Sub direct_draw_text_small(ByVal text_col As Color, ByVal pointx

As Integer, ByVal pointy As Integer, ByVal sizex As Integer, ByVal sizey As
Integer, ByVal drawtext As String)
>
> ' draw text using direct draw technique (called directly from main

thread)
> Dim r As New RectangleF(pointx, pointy, sizex, sizey)
> Dim rr As New RectangleF(0, 0, sizex, sizey)
> Dim b As New SolidBrush(text_col)
>
> bufferbmp = New Bitmap(sizex, sizey)
>
> ' to avoid flicker, double buffer onto bitmap then display
> Dim gxOff As Graphics = Graphics.FromImage(bufferbmp)
> gxOff.DrawString(drawtext, glf_font11tahoma, b, rr)
> gxOff.Dispose()
>
> ' draw
> Dim gxOn As Graphics = Me.CreateGraphics()
> gxOn.DrawImage(bufferbmp, pointx, pointy)
> gxOn.Dispose()
>
> ' manually release graphics objects
> b.Dispose()
> bufferbmp.Dispose()
>
> End Sub
>



 
Reply With Quote
 
=?Utf-8?B?UmljaGFyZCBKb25lcw==?=
Guest
Posts: n/a
 
      20th Feb 2004
Hi Ale

If I'm using a full-screen sized bitmap won't that slow things down a huge amount if I'mn constantly refreshing the whole screen

Or have I misunderstood

Richar


 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      20th Feb 2004
But you can use partial bitmap for drawing - Graphics.DrawImage allows
specifying both source and target rectangle. Think of this bitmap as an
off-screen canvas

"Richard Jones" <(E-Mail Removed)> wrote in message
news:49A6B637-B2EE-4C20-8523-(E-Mail Removed)...
> Hi Alex
>
> If I'm using a full-screen sized bitmap won't that slow things down a huge

amount if I'mn constantly refreshing the whole screen?
>
> Or have I misunderstood?
>
> Richard
>
>



 
Reply With Quote
 
=?Utf-8?B?UmljaGFyZCBKb25lcw==?=
Guest
Posts: n/a
 
      25th Feb 2004
Hi Ale
Thanks for the advice... I've done most of what you suggested, but I'm a bit stuck on what to do with the rectangles. I will be drawing various sizes and positions of rectangles; so I guess I need a separate rectangle instance of each size/position? I can't change the position or size of a rectangle after it's been instantiated can I? So will I have to create a new rectangle instance every time the draw method is called, and then dispose of it

Any ideas? I've put the beginnings of the class below so you can get an idea of where I'm going

Cheer

Ric

Public Class DirectDra

' --------------- Declare Class Variables ------------------

' Brushe
Private BrushWhite As New SolidBrush(Color.White
Private Brushcyan As New SolidBrush(Color.Cyan
Private Brushskyblue As New SolidBrush(Color.SkyBlue
Private Brushplum As New SolidBrush(Color.Plum
Private Brushlime As New SolidBrush(Color.Lime
Private Brushyellowgreen As New SolidBrush(Color.YellowGreen
Private Brushspringgreen As New SolidBrush(Color.SpringGreen
Private Brushdodgerblue As New SolidBrush(Color.Gold
Private Brushgold As New SolidBrush(Color.Gold

' Rectangle
' ??

' Font
Private f_arial_10 As New Font("arial", 10, FontStyle.Regular
Private f_tahoma_10 As New Font("tahoma", 10, FontStyle.Regular
Private f_arial_11 As New Font("arial", 11, FontStyle.Regular
Private f_tahoma_11 As New Font("tahoma", 11, FontStyle.Regular
Private f_arial_12 As New Font("arial", 12, FontStyle.Regular
Private f_tahoma_12 As New Font("tahoma", 12, FontStyle.Regular
Private f_tahoma_70 As New Font("tahoma", 70, FontStyle.Regular

' Bitmap
Private bmpOff As New Bitmap(640, 480) ' off-screen bitmap : full scree

' Graphics Object
Private gxOff As Graphics = Graphics.FromImage(bmpOff) ' graphics object associated with offscreen drawin

'Private r As New RectangleF(pointx, pointy, sizex, sizey
'Private rr As New RectangleF(0, 0, sizex, sizey
'Private b As New SolidBrush(text_col

' ------------------- Create Properties ---------------------

' -------------------- Create Methods -----------------------
Public Sub draw_text(ByVal text_col As String, ByVal pointx As Integer, ByVal pointy As Integer, ByVal sizex As Integer, ByVal sizey As Integer, ByVal drawtext As String, ByVal e As System.Windows.Forms.PaintEventArgs

' To avoid flicker, double buffer onto bitmap then display
' clear the section of bitma
' to do : need to handle rectangles..

' decide what colour this is and draw text onto bitma
Select Case text_co
Case "white
gxOff.DrawString(drawtext, f_tahoma_10, BrushWhite, pointx, pointy
Case "cyan
gxOff.DrawString(drawtext, f_tahoma_10, Brushcyan, pointx, pointy
Case "dodgerblue
gxOff.DrawString(drawtext, f_tahoma_10, Brushdodgerblue, pointx, pointy
Case "skyblue
gxOff.DrawString(drawtext, f_tahoma_10, Brushskyblue, pointx, pointy
Case "lime
gxOff.DrawString(drawtext, f_tahoma_10, Brushlime, pointx, pointy
Case "yellowgreen
gxOff.DrawString(drawtext, f_tahoma_10, Brushyellowgreen, pointx, pointy
Case "springgreen
gxOff.DrawString(drawtext, f_tahoma_10, Brushspringgreen, pointx, pointy
Case "plum
gxOff.DrawString(drawtext, f_tahoma_10, Brushplum, pointx, pointy
Case "gold
gxOff.DrawString(drawtext, f_tahoma_10, Brushgold, pointx, pointy

End Selec

' Draw bitmap section onto scree
' this bit draws the appropriate section of bmpOff (written to above) to the passed graphics objec
' r needs to be sorted out, as does the last paramete
e.Graphics.DrawImage(bmpOff, r, pointx, pointy, sizex, sizey, GraphicsUnit.Pixel, 0

End Su

End Class
 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      27th Feb 2004
Actually internal represenation of a rectangle consists of X, Y (left top
corner) and cx, cy (dimensions). All 4 are settable independently. THis
means you can use just one rectangle and keep changing its size and position
as needed

"Richard Jones" <(E-Mail Removed)> wrote in message
news:0EC9ED2E-18BB-406E-A6D4-(E-Mail Removed)...
> Hi Alex
> Thanks for the advice... I've done most of what you suggested, but I'm a

bit stuck on what to do with the rectangles. I will be drawing various sizes
and positions of rectangles; so I guess I need a separate rectangle instance
of each size/position? I can't change the position or size of a rectangle
after it's been instantiated can I? So will I have to create a new rectangle
instance every time the draw method is called, and then dispose of it?
>
> Any ideas? I've put the beginnings of the class below so you can get an

idea of where I'm going.
>
> Cheers
>
> Rich
>
>
> Public Class DirectDraw
>
> ' --------------- Declare Class Variables -------------------
>
> ' Brushes
> Private BrushWhite As New SolidBrush(Color.White)
> Private Brushcyan As New SolidBrush(Color.Cyan)
> Private Brushskyblue As New SolidBrush(Color.SkyBlue)
> Private Brushplum As New SolidBrush(Color.Plum)
> Private Brushlime As New SolidBrush(Color.Lime)
> Private Brushyellowgreen As New SolidBrush(Color.YellowGreen)
> Private Brushspringgreen As New SolidBrush(Color.SpringGreen)
> Private Brushdodgerblue As New SolidBrush(Color.Gold)
> Private Brushgold As New SolidBrush(Color.Gold)
>
> ' Rectangles
> ' ???
>
> ' Fonts
> Private f_arial_10 As New Font("arial", 10, FontStyle.Regular)
> Private f_tahoma_10 As New Font("tahoma", 10, FontStyle.Regular)
> Private f_arial_11 As New Font("arial", 11, FontStyle.Regular)
> Private f_tahoma_11 As New Font("tahoma", 11, FontStyle.Regular)
> Private f_arial_12 As New Font("arial", 12, FontStyle.Regular)
> Private f_tahoma_12 As New Font("tahoma", 12, FontStyle.Regular)
> Private f_tahoma_70 As New Font("tahoma", 70, FontStyle.Regular)
>
> ' Bitmaps
> Private bmpOff As New Bitmap(640, 480) ' off-screen bitmap : full

screen
>
> ' Graphics Objects
> Private gxOff As Graphics = Graphics.FromImage(bmpOff) ' graphics

object associated with offscreen drawing
>
> 'Private r As New RectangleF(pointx, pointy, sizex, sizey)
> 'Private rr As New RectangleF(0, 0, sizex, sizey)
> 'Private b As New SolidBrush(text_col)
>
>
> ' ------------------- Create Properties ----------------------
>
>
> ' -------------------- Create Methods ------------------------
> Public Sub draw_text(ByVal text_col As String, ByVal pointx As

Integer, ByVal pointy As Integer, ByVal sizex As Integer, ByVal sizey As
Integer, ByVal drawtext As String, ByVal e As
System.Windows.Forms.PaintEventArgs)
>
> ' To avoid flicker, double buffer onto bitmap then display.
> ' clear the section of bitmap
> ' to do : need to handle rectangles...
>
> ' decide what colour this is and draw text onto bitmap
> Select Case text_col
> Case "white"
> gxOff.DrawString(drawtext, f_tahoma_10, BrushWhite,

pointx, pointy)
> Case "cyan"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushcyan, pointx,

pointy)
> Case "dodgerblue"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushdodgerblue,

pointx, pointy)
> Case "skyblue"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushskyblue,

pointx, pointy)
> Case "lime"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushlime, pointx,

pointy)
> Case "yellowgreen"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushyellowgreen,

pointx, pointy)
> Case "springgreen"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushspringgreen,

pointx, pointy)
> Case "plum"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushplum, pointx,

pointy)
> Case "gold"
> gxOff.DrawString(drawtext, f_tahoma_10, Brushgold, pointx,

pointy)
>
> End Select
>
> ' Draw bitmap section onto screen
> ' this bit draws the appropriate section of bmpOff (written to

above) to the passed graphics object
> ' r needs to be sorted out, as does the last parameter
> e.Graphics.DrawImage(bmpOff, r, pointx, pointy, sizex, sizey,

GraphicsUnit.Pixel, 0)
>
> End Sub
>
> End Class



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MLC High Performance SSD-CORSAIR Performance Series 128GB PC/NB Dual Platform Test windwithme User Reviews 4 17th Jun 2011 07:09 AM
SQL 2000 performance objects doesnt appear on Performance monitor =?Utf-8?B?UFY=?= Microsoft Windows 2000 1 25th Oct 2006 03:57 AM
Strange Performance Counter performance problem in Windows Service application Tomasz Jastrzebski Microsoft Dot NET Framework 8 23rd Oct 2006 09:35 AM
Outlook 2003 - slow performance, why use the word performance because it barely is Anthony Smith Microsoft Outlook Discussion 0 12th Nov 2004 05:08 PM
/CLR floating point performance, inter-assembly function call performance Bern McCarty Microsoft VC .NET 13 17th May 2004 07:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:32 PM.