# The slow screen redraws on the movement of the mouse

**URL:** <https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175>\
**Category:** WPF\
**Created:** [March 14, 2012, 5:18am UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175 "2012-03-14T05:18:10Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 3, 2012, 8:23pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/21 "2012-04-03T20:23:11Z")

</div>

Unfortunately,&nbsp;I&nbsp;do&nbsp;not&nbsp;agree&nbsp;that&nbsp;this&nbsp;optimization&nbsp;process.&nbsp;This&nbsp;is&nbsp;a&nbsp;bug.&nbsp;I&nbsp;just&nbsp;have&nbsp;a&nbsp;computer&nbsp;powerful&nbsp;enough&nbsp;(8&nbsp;gigabytes&nbsp;of&nbsp;RAM),&nbsp;but&nbsp;if&nbsp;I&nbsp;run&nbsp;it&nbsp;on&nbsp;a&nbsp;weaker&nbsp;machine&nbsp;(2&nbsp;gigibayta&nbsp;RAM),&nbsp;and&nbsp;200-300&nbsp;MB&nbsp;of&nbsp;upload&nbsp;to&nbsp;vector&nbsp;map,&nbsp;then&nbsp;retest&nbsp;the&nbsp;program&nbsp;crashes&nbsp;with&nbsp;an&nbsp;error&nbsp;out&nbsp;of&nbsp;memory&nbsp;exception.&nbsp;The&nbsp;same&nbsp;can&nbsp;be&nbsp;seen&nbsp;in&nbsp;other&nbsp;posts&nbsp;that&nbsp;I&nbsp;quoted&nbsp;above.&nbsp;In&nbsp;my&nbsp;opinion&nbsp;the&nbsp;program&nbsp;should&nbsp;not&nbsp;crush,&nbsp;even&nbsp;waiting&nbsp;for&nbsp;a&nbsp;second&nbsp;and&nbsp;resets&nbsp;the&nbsp;memory&nbsp;or&nbsp;even&nbsp;an&nbsp;action,&nbsp;but&nbsp;did&nbsp;not&nbsp;crush&nbsp;at&nbsp;all.

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 3, 2012, 8:56pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/22 "2012-04-03T20:56:55Z")

</div>

` In the meantime, can you make sure than you have the option Platform target to x64 under Project/Properties…/Build? I think this can help. Thank you. `&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;problem&nbsp;manifests&nbsp;itself&nbsp;in&nbsp;the&nbsp;assembly&nbsp;under&nbsp;x64.&nbsp;Moreover,&nbsp;it&nbsp;is&nbsp;not&nbsp;a&nbsp;solution&nbsp;because&nbsp;I&nbsp;need&nbsp;to&nbsp;run&nbsp;the&nbsp;program&nbsp;and&nbsp;will&nbsp;be&nbsp;for&nbsp;32-bit&nbsp;builds.

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 3, 2012, 11:25pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/23 "2012-04-03T23:25:23Z")

</div>

The&nbsp;above&nbsp;test&nbsp;I&nbsp;performed&nbsp;on&nbsp;the&nbsp;machine:&nbsp;  
&nbsp;Intel&nbsp;Core&nbsp;i7&nbsp;3.4Ghz,&nbsp;8&nbsp;gb&nbsp;RAM,&nbsp;assembly&nbsp;in&nbsp;x86

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [April 4, 2012, 9:46am UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/24 "2012-04-04T09:46:14Z")

</div>

Alex,

&nbsp;Thank&nbsp;you&nbsp;for&nbsp;providing&nbsp;that&nbsp;additional&nbsp;information&nbsp;and&nbsp;your&nbsp;opinion.&nbsp;We&nbsp;value&nbsp;your&nbsp;point&nbsp;of&nbsp;view&nbsp;and&nbsp;this&nbsp;is&nbsp;going&nbsp;to&nbsp;be&nbsp;communicated&nbsp;to&nbsp;the&nbsp;Development&nbsp;team.&nbsp;I&nbsp;will&nbsp;let&nbsp;you&nbsp;know&nbsp;as&nbsp;soon&nbsp;as&nbsp;I&nbsp;have&nbsp;the&nbsp;results&nbsp;from&nbsp;the&nbsp;findings&nbsp;of&nbsp;the&nbsp;Development&nbsp;team.&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 4, 2012, 10:13am UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/25 "2012-04-04T10:13:50Z")

</div>

Thank&nbsp;you&nbsp;very&nbsp;much,Val,&nbsp;for&nbsp;your&nbsp;cooperation&nbsp;and&nbsp;your&nbsp;answers!&nbsp;It&nbsp;is&nbsp;really&nbsp;nice.&nbsp;With&nbsp;your&nbsp;very&nbsp;nice&nbsp;work.&nbsp;  
&nbsp;I’ll&nbsp;wait&nbsp;for&nbsp;news&nbsp;from&nbsp;you!

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [April 10, 2012, 4:07pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/26 "2012-04-10T16:07:06Z")

</div>

Hello&nbsp;Alex,

Thanks&nbsp;for&nbsp;your&nbsp;waiting,&nbsp;unfortunately&nbsp;we&nbsp;tried&nbsp;&nbsp;the&nbsp;latest&nbsp;code&nbsp;on&nbsp;a&nbsp;Virtual&nbsp;machine&nbsp;with&nbsp;bad&nbsp;hardware,&nbsp;but&nbsp;seems&nbsp;like&nbsp;the&nbsp;memory&nbsp;usage&nbsp;is&nbsp;normal,&nbsp;here&nbsp;we&nbsp;make&nbsp;a&nbsp;short&nbsp;video&nbsp;about&nbsp;it&nbsp;,&nbsp;please&nbsp;check&nbsp;it&nbsp;out,&nbsp;and&nbsp;let&nbsp;us&nbsp;know&nbsp;what&nbsp;you&nbsp;got.

[download.thinkgeo.com/forums/MemoryUsage.zip](http://download.thinkgeo.com/forums/MemoryUsage.zip)

Also&nbsp;could&nbsp;you&nbsp;please&nbsp;get&nbsp;the&nbsp;latest&nbsp;version&nbsp;and&nbsp;have&nbsp;another&nbsp;try?

Regards,

Gary

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 10, 2012, 8:25pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/27 "2012-04-10T20:25:14Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;video.&nbsp;Let's&nbsp;deal&nbsp;further.&nbsp;  
  
  
  
1)&nbsp;What&nbsp;is&nbsp;your&nbsp;screen&nbsp;resolution?&nbsp;The&nbsp;fact&nbsp;that&nbsp;it&nbsp;directly&nbsp;affects&nbsp;the&nbsp;amount&nbsp;of&nbsp;memory&nbsp;consumed.&nbsp;On&nbsp;the&nbsp;monitor&nbsp;in&nbsp;17-inch&nbsp;jump&nbsp;in&nbsp;memory&nbsp;of&nbsp;about&nbsp;a&nbsp;factor&nbsp;of&nbsp;4-5&nbsp;relative&nbsp;to&nbsp;the&nbsp;original,&nbsp;but&nbsp;on&nbsp;the&nbsp;monitor&nbsp;24&nbsp;inch&nbsp;(1600x1200&nbsp;full&nbsp;screen&nbsp;mode)&nbsp;jump&nbsp;by&nbsp;10&nbsp;times&nbsp;or&nbsp;more.&nbsp;  
  
  
  
2)&nbsp;You&nbsp;have&nbsp;used&nbsp;too&nbsp;"easy"&nbsp;test.&nbsp;The&nbsp;movement&nbsp;is&nbsp;very&nbsp;slow&nbsp;rotation,&nbsp;too.&nbsp;In&nbsp;real&nbsp;life,&nbsp;this&nbsp;is&nbsp;not&nbsp;always&nbsp;the&nbsp;case.&nbsp;Try&nbsp;to&nbsp;rotate&nbsp;the&nbsp;object&nbsp;does&nbsp;not&nbsp;hold&nbsp;(that&nbsp;did&nbsp;not&nbsp;work&nbsp;the&nbsp;garbage&nbsp;collector)&nbsp;in&nbsp;at&nbsp;least&nbsp;10-15&nbsp;seconds&nbsp;with&nbsp;a&nbsp;fast&nbsp;speed&nbsp;on&nbsp;the&nbsp;big&nbsp;screen,&nbsp;and&nbsp;you'll&nbsp;be&nbsp;surprised.&nbsp;I&nbsp;tested&nbsp;it&nbsp;on&nbsp;4&nbsp;different&nbsp;machines&nbsp;not&nbsp;connected&nbsp;to&nbsp;each&nbsp;other.&nbsp;  
  
  
  
3)&nbsp;Let's&nbsp;analyze&nbsp;the&nbsp;results&nbsp;you&nbsp;got.&nbsp;Initially,&nbsp;your&nbsp;application&nbsp;is&nbsp;49&nbsp;megabytes,&nbsp;but&nbsp;at&nbsp;the&nbsp;time&nbsp;the&nbsp;landfill&nbsp;is&nbsp;rising&nbsp;up&nbsp;to&nbsp;180&nbsp;megabytes!&nbsp;And&nbsp;it&nbsp;is&nbsp;not&nbsp;fast&nbsp;and&nbsp;not&nbsp;on&nbsp;the&nbsp;big&nbsp;screen.&nbsp;Try&nbsp;the&nbsp;on-screen&nbsp;24-inch&nbsp;full&nbsp;screen&nbsp;to&nbsp;do&nbsp;the&nbsp;same.&nbsp;We&nbsp;have&nbsp;about&nbsp;400-600&nbsp;megabytes,&nbsp;but&nbsp;it's&nbsp;just&nbsp;a&nbsp;huge&nbsp;memory&nbsp;leak&nbsp;in&nbsp;the&nbsp;creation&nbsp;of&nbsp;a&nbsp;simple&nbsp;polygon!!!&nbsp;Do&nbsp;you&nbsp;think&nbsp;this&nbsp;"is&nbsp;normal"?&nbsp;  
  
  
  
These&nbsp;problems&nbsp;arise&nbsp;not&nbsp;only&nbsp;from&nbsp;me,&nbsp;as&nbsp;I&nbsp;said&nbsp;above,&nbsp;so&nbsp;what&nbsp;I'm&nbsp;describing&nbsp;is&nbsp;not&nbsp;my&nbsp;imagination&nbsp;:)&nbsp;Add&nbsp;to&nbsp;that&nbsp;the&nbsp;original&nbsp;memory&nbsp;consumption&nbsp;of&nbsp;200-400&nbsp;megabytes&nbsp;(vector,&nbsp;tools&nbsp;and&nbsp;so&nbsp;on)&nbsp;in&nbsp;a&nbsp;24-inch&nbsp;monitor&nbsp;(all&nbsp;the&nbsp;best&nbsp;for&nbsp;cartographers)&nbsp;and&nbsp;full-screen&nbsp;mode,&nbsp;increase&nbsp;the&nbsp;speed&nbsp;of&nbsp;the&nbsp;editor&nbsp;and&nbsp;the&nbsp;program&nbsp;is&nbsp;easy&nbsp;to&nbsp;fall&nbsp;with&nbsp;the&nbsp;exception&nbsp;of&nbsp;out&nbsp;of&nbsp;memory&nbsp;exception.&nbsp;Even&nbsp;in&nbsp;your&nbsp;application&nbsp;blank&nbsp;with&nbsp;a&nbsp;small&nbsp;screen&nbsp;(even&nbsp;if&nbsp;you&nbsp;have&nbsp;24&nbsp;inches&nbsp;he&nbsp;is&nbsp;not&nbsp;deployed&nbsp;on&nbsp;the&nbsp;entire&nbsp;screen)&nbsp;and&nbsp;the&nbsp;relatively&nbsp;slow&nbsp;mode&nbsp;of&nbsp;the&nbsp;memory&nbsp;increases&nbsp;by&nbsp;3-4&nbsp;times!&nbsp;it&nbsp;is&nbsp;very&nbsp;very&nbsp;much.

For&nbsp;example:

gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/39/aft/10170/afv/topic/Default.aspx

gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/39/aft/9278/afv/topic/Default.aspx

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [April 12, 2012, 10:37am UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/28 "2012-04-12T10:37:18Z")

</div>

Hello&nbsp;Alex,

Thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information,&nbsp;as&nbsp;I&nbsp;said&nbsp;in&nbsp;post&nbsp;:&nbsp;[gis.thinkgeo.com/Support/Dis...fault.aspx](http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/39/aft/10170/afv/topic/Default.aspx)&nbsp;,&nbsp;we&nbsp;cannot&nbsp;control&nbsp;the&nbsp;GC,&nbsp;so&nbsp;there&nbsp;are&nbsp;2&nbsp;options&nbsp;you&nbsp;can&nbsp;choose:

1.&nbsp;Set&nbsp;the&nbsp;wpfMap.EditOverlay.RenderMode&nbsp;to&nbsp;RenderMode.GdiPlus.

2.&nbsp;Use&nbsp;the&nbsp;code&nbsp;below

`wpfMap1.EditOverlay.Drawn += new EventHandler<DrawnOverlayEventArgs>(EditOverlay_Drawn);void EditOverlay_Drawn(object sender, DrawnOverlayEventArgs e)       {           GC.Collect();       }`Regards,

Gary

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 12, 2012, 10:17pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/29 "2012-04-12T22:17:14Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;reply.&nbsp;This&nbsp;code&nbsp;definitely&nbsp;helps&nbsp;(just&nbsp;need&nbsp;to&nbsp;use&nbsp;Drawing&nbsp;but&nbsp;not&nbsp;Drawn).&nbsp;&nbsp;  
&nbsp;But&nbsp;I&nbsp;think&nbsp;this&nbsp;is&nbsp;not&nbsp;the&nbsp;correct&nbsp;solution&nbsp;(which&nbsp;incidentally&nbsp;says&nbsp;a&nbsp;well-known&nbsp;Jeffrey&nbsp;Richter),&nbsp;for&nbsp;several&nbsp;reasons:&nbsp;  
&nbsp;1)&nbsp;There&nbsp;is&nbsp;no&nbsp;guarantee&nbsp;that&nbsp;the&nbsp;garbage&nbsp;collector&nbsp;is&nbsp;triggered&nbsp;at&nbsp;a&nbsp;time&nbsp;when&nbsp;we&nbsp;are&nbsp;trying&nbsp;to&nbsp;call.&nbsp;  
&nbsp;2)&nbsp;increasing&nbsp;the&nbsp;load&nbsp;on&nbsp;the&nbsp;processor&nbsp;and,&nbsp;generally&nbsp;speaking,&nbsp;not&nbsp;very&nbsp;clear&nbsp;until&nbsp;the&nbsp;impact&nbsp;is&nbsp;on&nbsp;other&nbsp;processes&nbsp;or&nbsp;not&nbsp;(permanent&nbsp;call&nbsp;the&nbsp;garbage&nbsp;collector).&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;understand&nbsp;that&nbsp;this&nbsp;problem&nbsp;is&nbsp;quite&nbsp;extensive.&nbsp;I&nbsp;watched&nbsp;the&nbsp;memory&nbsp;profiler&nbsp;that&nbsp;you&nbsp;have&nbsp;going&nbsp;on&nbsp;and&nbsp;where&nbsp;it&nbsp;goes&nbsp;memory,&nbsp;and&nbsp;I&nbsp;realized&nbsp;that&nbsp;you’re&nbsp;drawing&nbsp;a&nbsp;Bitmaps&nbsp;all&nbsp;time.&nbsp;Maybe&nbsp;you&nbsp;have&nbsp;not&nbsp;called&nbsp;destruction&nbsp;of&nbsp;Bitmap&nbsp;(System.Windows.Media.Imaging),&nbsp;which&nbsp;we&nbsp;no&nbsp;longer&nbsp;need?&nbsp;Just&nbsp;from&nbsp;memory&nbsp;at&nbsp;time&nbsp;T&nbsp;(with&nbsp;a&nbsp;strong&nbsp;rotation&nbsp;of&nbsp;the&nbsp;object&nbsp;to&nbsp;the&nbsp;scheme&nbsp;that&nbsp;I&nbsp;described&nbsp;above),&nbsp;we&nbsp;get&nbsp;about&nbsp;200&nbsp;bitmap-s,&nbsp;each&nbsp;of&nbsp;which&nbsp;is&nbsp;5&nbsp;megabytes.&nbsp;Although&nbsp;it&nbsp;is&nbsp;doubtful&nbsp;that&nbsp;we&nbsp;need&nbsp;all&nbsp;200&nbsp;pieces.&nbsp;Maybe&nbsp;worth&nbsp;a&nbsp;look&nbsp;in&nbsp;this&nbsp;direction?

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 12, 2012, 10:28pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/30 "2012-04-12T22:28:23Z")

</div>

I&nbsp;looked&nbsp;at&nbsp;your&nbsp;code&nbsp;by&nbsp;disassembler.&nbsp;Do&nbsp;you&nbsp;have&nbsp;a&nbsp;function&nbsp;in&nbsp;InteractiveOverlay&nbsp;responsible&nbsp;for&nbsp;rendering:  
  
``private&nbsp;void&nbsp;\u0036xQ\u003D(LayerTile&nbsp;\u0037BQ\u003D)  
  
&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;num1&nbsp;=&nbsp;(int)&nbsp;this.MapArguments.ActualWidth;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;num2&nbsp;=&nbsp;(int)&nbsp;this.MapArguments.ActualHeight;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(this.RenderMode&nbsp;==&nbsp;RenderMode.DrawingVisual)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**&nbsp;&nbsp;DrawingVisualGeoCanvas&nbsp;drawingVisualGeoCanvas&nbsp;=&nbsp;new&nbsp;DrawingVisualGeoCanvas();**  
  
**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RenderTargetBitmap&nbsp;renderTargetBitmap&nbsp;=&nbsp;new&nbsp;&nbsp;RenderTargetBitmap(num1,&nbsp;num2,&nbsp;(double)&nbsp;drawingVisualGeoCanvas.Dpi,&nbsp;&nbsp;(double)&nbsp;drawingVisualGeoCanvas.Dpi,&nbsp;PixelFormats.Pbgra32);**  
  
**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drawingVisualGeoCanvas.BeginDrawing((object)&nbsp;renderTargetBitmap,&nbsp;param0.TargetExtent,&nbsp;this.MapArguments.MapUnit);**  
  
**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.DrawTileCore((GeoCanvas)&nbsp;drawingVisualGeoCanvas);**  
  
**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drawingVisualGeoCanvas.EndDrawing();**  
  
**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param0.CommitDrawing((GeoCanvas)&nbsp;drawingVisualGeoCanvas,&nbsp;(object)&nbsp;renderTargetBitmap);**  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using&nbsp;(Bitmap&nbsp;bitmap&nbsp;=&nbsp;new&nbsp;Bitmap(num1,&nbsp;num2))  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GdiPlusGeoCanvas&nbsp;gdiPlusGeoCanvas&nbsp;=&nbsp;new&nbsp;GdiPlusGeoCanvas();  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gdiPlusGeoCanvas.BeginDrawing((object)&nbsp;bitmap,&nbsp;param0.TargetExtent,&nbsp;this.MapArguments.MapUnit);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.DrawTileCore((GeoCanvas)&nbsp;gdiPlusGeoCanvas);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gdiPlusGeoCanvas.EndDrawing();  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param0.CommitDrawing((GeoCanvas)&nbsp;gdiPlusGeoCanvas,&nbsp;hxQ\u003D.yRQ\u003D((object)&nbsp;bitmap));  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
  
&nbsp;&nbsp;&nbsp;&nbsp;}

If&nbsp;you&nbsp;use&nbsp;RenderMode&nbsp;=&nbsp;DrawingVisual&nbsp;(namely&nbsp;the&nbsp;need&nbsp;to&nbsp;use&nbsp;it,&nbsp;and&nbsp;otherwise&nbsp;there&nbsp;are&nbsp;significant&nbsp;gaps&nbsp;in&nbsp;the&nbsp;code).&nbsp;If&nbsp;you&nbsp;use&nbsp;RenderMode!&nbsp;=&nbsp;DrawingVisual&nbsp;(even&nbsp;though&nbsp;it&nbsp;was&nbsp;his&nbsp;and&nbsp;should&nbsp;be&nbsp;used&nbsp;differently,&nbsp;there&nbsp;are&nbsp;significant&nbsp;gaps&nbsp;in&nbsp;the&nbsp;code),&nbsp;then&nbsp;you&nbsp;allocate&nbsp;memory&nbsp;for&nbsp;Bitmap&nbsp;is&nbsp;using&nbsp;{},&nbsp;so&nbsp;it&nbsp;is&nbsp;automatically&nbsp;cleared.&nbsp;But&nbsp;if&nbsp;RenderMode&nbsp;=&nbsp;DrawingVisual,&nbsp;then&nbsp;you&nbsp;simply&nbsp;create&nbsp;an&nbsp;object&nbsp;renderTargetBitmap&nbsp;and&nbsp;nowhere&nbsp;do&nbsp;with&nbsp;it&nbsp;not&nbsp;happening.&nbsp;I&nbsp;think&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;

**param0.CommitDrawing((GeoCanvas)&nbsp;drawingVisualGeoCanvas,&nbsp;(object)&nbsp;renderTargetBitmap);**

`param0.CommitDrawing((GeoCanvas) drawingVisualGeoCanvas, (object) renderTargetBitmap);`

&nbsp;it&nbsp;should&nbsp;be&nbsp;cleaned&nbsp;at&nbsp;the&nbsp;end&nbsp;(equal&nbsp;null&nbsp;/&nbsp;dispose&nbsp;()&nbsp;and&nbsp;so&nbsp;on).

P.S.&nbsp;I&nbsp;tried&nbsp;to&nbsp;use&nbsp;the&nbsp;gdiplus,&nbsp;but&nbsp;I'm&nbsp;not&nbsp;very&nbsp;pleased&nbsp;with&nbsp;the&nbsp;rapid&nbsp;rotation&nbsp;of&nbsp;the&nbsp;reaction,&nbsp;there&nbsp;is&nbsp;sometimes&nbsp;a&nbsp;half-second&nbsp;delay,&nbsp;but&nbsp;they&nbsp;are&nbsp;visible&nbsp;and&nbsp;unpleasant.&nbsp;If&nbsp;there&nbsp;is&nbsp;no&nbsp;such&nbsp;DrawingVisual.&nbsp;In&nbsp;general,&nbsp;the&nbsp;behavior&nbsp;that&nbsp;got&nbsp;hung&nbsp;on&nbsp;the&nbsp;DrawingVisual&nbsp;+&nbsp;GC.Collect().&nbsp;I&nbsp;really&nbsp;like&nbsp;it&nbsp;except&nbsp;that&nbsp;it&nbsp;is&nbsp;necessary&nbsp;to&nbsp;cause&nbsp;each&nbsp;time&nbsp;GC.

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [April 18, 2012, 10:59am UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/31 "2012-04-18T10:59:16Z")

</div>

Hello&nbsp;Alex,

Have&nbsp;you&nbsp;try&nbsp;to&nbsp;update&nbsp;the&nbsp;.net&nbsp;framework&nbsp;3.5&nbsp;sp1?&nbsp;&nbsp;because&nbsp;I&nbsp;found&nbsp;that&nbsp;in&nbsp;this&nbsp;service&nbsp;pack,&nbsp;Microsoft&nbsp;solved&nbsp;a&nbsp;memory&nbsp;leak&nbsp;of&nbsp;the&nbsp;RenderTargetBitmap&nbsp;class,&nbsp;[support.microsoft.com/kb/967634/](http://support.microsoft.com/kb/967634/)&nbsp;,&nbsp;I&nbsp;did&nbsp;some&nbsp;test&nbsp;on&nbsp;a&nbsp;computer&nbsp;which&nbsp;Memory&nbsp;is&nbsp;700MB&nbsp;and&nbsp;has&nbsp;applied&nbsp;the&nbsp;.net&nbsp;3.5&nbsp;sp1,&nbsp;before&nbsp;I&nbsp;ran&nbsp;the&nbsp;HowDoISamples,&nbsp;the&nbsp;memory&nbsp;has&nbsp;500MB&nbsp;used,&nbsp;so&nbsp;that&nbsp;means&nbsp;I&nbsp;have&nbsp;only&nbsp;200MB&nbsp;to&nbsp;run&nbsp;the&nbsp;sample,&nbsp;as&nbsp;I&nbsp;ran&nbsp;the&nbsp;sample&nbsp;and&nbsp;rotate&nbsp;the&nbsp;shape&nbsp;rapidly&nbsp;the&nbsp;memory&nbsp;never&nbsp;reach&nbsp;700MB&nbsp;and&nbsp;the&nbsp;OutOfMemoryException&nbsp;hasn’t&nbsp;been&nbsp;thrown,&nbsp;so&nbsp;I&nbsp;think&nbsp;the&nbsp;GC&nbsp;took&nbsp;care&nbsp;of&nbsp;the&nbsp;memory.

Please&nbsp;let&nbsp;me&nbsp;know&nbsp;your&nbsp;result.

Regards,

Gary

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 18, 2012, 10:14pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/32 "2012-04-18T22:14:44Z")

</div>

Thank&nbsp;you,&nbsp;Gary.&nbsp;  
  
1)&nbsp;Windows&nbsp;7&nbsp;already&nbsp;has&nbsp;.Net&nbsp;framework&nbsp;3.5&nbsp;sp1;&nbsp;  
  
2)&nbsp;I&nbsp;run&nbsp;under&nbsp;.net&nbsp;framework&nbsp;4.0,&nbsp;which&nbsp;I&nbsp;think&nbsp;contains&nbsp;all&nbsp;fixed&nbsp;bugs&nbsp;of&nbsp;previous&nbsp;versions.&nbsp;

In&nbsp;any&nbsp;case,&nbsp;I&nbsp;have&nbsp;collected&nbsp;a&nbsp;3.5,&nbsp;but&nbsp;nothing&nbsp;has&nbsp;changed.

---

<div class="post-metadata">

**Author:** ![Alex1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://community.thinkgeo.com/u/Alex1)\
**Post date:** [April 19, 2012, 9:29pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/33 "2012-04-19T21:29:46Z")

</div>

We&nbsp;have&nbsp;within&nbsp;the&nbsp;team&nbsp;analyzed&nbsp;the&nbsp;existing&nbsp;problem&nbsp;and&nbsp;discovered&nbsp;that&nbsp;the&nbsp;problem&nbsp;is&nbsp;inside&nbsp;the&nbsp;RenderTargetBitmap&nbsp;from&nbsp;Microsoft.&nbsp;&nbsp;  
&nbsp;Many&nbsp;people&nbsp;complain&nbsp;that&nbsp;there&nbsp;is&nbsp;a&nbsp;problem,&nbsp;everybody&nbsp;use&nbsp;GC.Collect&nbsp;(),&nbsp;but&nbsp;then&nbsp;again&nbsp;everyone&nbsp;is&nbsp;saying&nbsp;that&nbsp;this&nbsp;is&nbsp;a&nbsp;bad&nbsp;decision.&nbsp;Microsoft&nbsp;released&nbsp;a&nbsp;patch&nbsp;supposed&nbsp;to&nbsp;fix&nbsp;this&nbsp;bug,&nbsp;but&nbsp;neither&nbsp;we&nbsp;nor&nbsp;the&nbsp;many&nbsp;other&nbsp;users&nbsp;of&nbsp;the&nbsp;patch&nbsp;has&nbsp;not&nbsp;changed&nbsp;anything.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Let’s&nbsp;try&nbsp;to&nbsp;go&nbsp;on&nbsp;the&nbsp;other&nbsp;hand,&nbsp;why&nbsp;do&nbsp;you&nbsp;use&nbsp;this&nbsp;class&nbsp;(RenderTargetBitmap&nbsp;)?&nbsp;There&nbsp;may&nbsp;be&nbsp;other&nbsp;solutions&nbsp;with&nbsp;the&nbsp;use&nbsp;of&nbsp;any&nbsp;other&nbsp;class,&nbsp;for&nbsp;example&nbsp;Bitmap?&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [April 26, 2012, 10:28am UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/34 "2012-04-26T10:28:44Z")

</div>

Hello&nbsp;Alex,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;suggestion&nbsp;to&nbsp;use&nbsp;the&nbsp;other&nbsp;classes&nbsp;rather&nbsp;than&nbsp;RenderTargetBitmap&nbsp;in&nbsp;wpf,&nbsp;but&nbsp;as&nbsp;far&nbsp;as&nbsp;we&nbsp;know,&nbsp;there&nbsp;isn’t&nbsp;any&nbsp;other&nbsp;options&nbsp;for&nbsp;us&nbsp;now,&nbsp;we&nbsp;will&nbsp;do&nbsp;more&nbsp;investigation&nbsp;after&nbsp;the&nbsp;6.0&nbsp;release,&nbsp;and&nbsp;if&nbsp;we&nbsp;find&nbsp;any&nbsp;way&nbsp;to&nbsp;fix&nbsp;this,&nbsp;I&nbsp;will&nbsp;post&nbsp;here&nbsp;and&nbsp;let&nbsp;you&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [May 24, 2012, 3:27pm UTC](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175/35 "2012-05-24T15:27:40Z")

</div>

Hello&nbsp;Alex,

We&nbsp;actually&nbsp;considered&nbsp;all&nbsp;of&nbsp;the&nbsp;render&nbsp;solutions&nbsp;in&nbsp;WPF;&nbsp;but&nbsp;finally&nbsp;current&nbsp;way&nbsp;is&nbsp;the&nbsp;best&nbsp;one.&nbsp;For&nbsp;several&nbsp;reasons&nbsp;below,

1.&nbsp;We&nbsp;should&nbsp;know&nbsp;that&nbsp;current&nbsp;way&nbsp;is&nbsp;not&nbsp;a&nbsp;memory&nbsp;leak,&nbsp;for&nbsp;it&nbsp;can&nbsp;be&nbsp;collected&nbsp;by&nbsp;GC,&nbsp;even&nbsp;though&nbsp;it&nbsp;is&nbsp;not&nbsp;be&nbsp;collected&nbsp;in&nbsp;time.&nbsp;MS&nbsp;has&nbsp;a&nbsp;hotfix&nbsp;for&nbsp;this&nbsp;issue,&nbsp;please&nbsp;refer&nbsp;to&nbsp;this&nbsp;article.  
  
[support.microsoft.com/kb/967634/](http://support.microsoft.com/kb/967634/)

2.&nbsp;Current&nbsp;GeoCanvases&nbsp;are&nbsp;very&nbsp;stabled&nbsp;now,&nbsp;and&nbsp;they&nbsp;work&nbsp;fine&nbsp;in&nbsp;our&nbsp;scenarios.&nbsp;If&nbsp;we&nbsp;want&nbsp;a&nbsp;new&nbsp;drawing&nbsp;way,&nbsp;it&nbsp;&nbsp;will&nbsp;take&nbsp;time&nbsp;on&nbsp;testing&nbsp;all&nbsp;our&nbsp;scenarios&nbsp;and&nbsp;evaluate&nbsp;its&nbsp;performance&nbsp;and&nbsp;compatibility.  
  
3.&nbsp;To&nbsp;find&nbsp;a&nbsp;better&nbsp;balance&nbsp;between&nbsp;the&nbsp;speed&nbsp;and&nbsp;responding,&nbsp;DrawingVisual&nbsp;is&nbsp;the&nbsp;best&nbsp;choice&nbsp;which&nbsp;works&nbsp;with&nbsp;RenderTargetBitmap.&nbsp;Here&nbsp;is&nbsp;a&nbsp;related&nbsp;article.  
  
[msdn.microsoft.com/en-us/lib...al\_Objects](http://msdn.microsoft.com/en-us/library/bb613591.aspx#DrawingVisual_Objects)

Quote:  
  
The&nbsp;DrawingVisual&nbsp;object&nbsp;is&nbsp;a&nbsp;lightweight&nbsp;drawing&nbsp;class&nbsp;that&nbsp;is&nbsp;used&nbsp;to&nbsp;render&nbsp;shapes,&nbsp;images,&nbsp;or&nbsp;text.&nbsp;This&nbsp;class&nbsp;is&nbsp;considered&nbsp;lightweight&nbsp;because&nbsp;it&nbsp;does&nbsp;not&nbsp;provide&nbsp;layout&nbsp;or&nbsp;event&nbsp;handling,&nbsp;which&nbsp;improves&nbsp;its&nbsp;performance.&nbsp;For&nbsp;this&nbsp;reason,&nbsp;drawings&nbsp;are&nbsp;ideal&nbsp;for&nbsp;backgrounds&nbsp;and&nbsp;clip&nbsp;art.&nbsp;For&nbsp;more&nbsp;information,&nbsp;see&nbsp;Using&nbsp;DrawingVisual&nbsp;Objects.

4.&nbsp;Other&nbsp;than&nbsp;integrated&nbsp;WPF&nbsp;render&nbsp;methods,&nbsp;they&nbsp;have&nbsp;worse&nbsp;performance&nbsp;and&nbsp;lower&nbsp;responding,&nbsp;so&nbsp;we&nbsp;didn’t&nbsp;choose&nbsp;them.

5.&nbsp;The&nbsp;only&nbsp;last&nbsp;choice&nbsp;is&nbsp;using&nbsp;WritableBitmap,&nbsp;for&nbsp;the&nbsp;drawing&nbsp;performance&nbsp;might&nbsp;be&nbsp;good&nbsp;as&nbsp;this&nbsp;our&nbsp;current&nbsp;one,&nbsp;but&nbsp;it&nbsp;doesn’t&nbsp;support&nbsp;many&nbsp;effect&nbsp;we&nbsp;want&nbsp;to&nbsp;use,&nbsp;so&nbsp;most&nbsp;of&nbsp;our&nbsp;GeoStyles&nbsp;won’t&nbsp;be&nbsp;supported.

6.&nbsp;One&nbsp;comments&nbsp;is&nbsp;that&nbsp;if&nbsp;they&nbsp;want&nbsp;to&nbsp;change&nbsp;to&nbsp;use&nbsp;some&nbsp;other&nbsp;ways&nbsp;for&nbsp;rendering&nbsp;other&nbsp;than&nbsp;the&nbsp;WPF&nbsp;region,&nbsp;we&nbsp;might&nbsp;suggest&nbsp;use&nbsp;Windows&nbsp;Imaging&nbsp;Component&nbsp;extension,&nbsp;but&nbsp;I&nbsp;think&nbsp;it&nbsp;won’t&nbsp;be&nbsp;better&nbsp;than&nbsp;rendering&nbsp;with&nbsp;GDI+&nbsp;when&nbsp;rendering&nbsp;small&nbsp;features&nbsp;just&nbsp;like&nbsp;editing.

Please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know&nbsp;your&nbsp;queries.

Regards,

Gary

[Previous page](https://community.thinkgeo.com/t/the-slow-screen-redraws-on-the-movement-of-the-mouse/3175.md?page=1)
