Click here to Skip to main content
15,903,033 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Garbage Collection Pin
raghu.g6-Oct-09 17:56
raghu.g6-Oct-09 17:56 
AnswerRe: Garbage Collection Pin
N a v a n e e t h6-Oct-09 18:03
N a v a n e e t h6-Oct-09 18:03 
AnswerRe: Garbage Collection Pin
supercat97-Oct-09 7:44
supercat97-Oct-09 7:44 
GeneralRe: Garbage Collection Pin
KSR817-Oct-09 11:15
KSR817-Oct-09 11:15 
QuestionNCoverExplorer Report & MSBuild Pin
Jammer6-Oct-09 10:48
Jammer6-Oct-09 10:48 
AnswerRe: NCoverExplorer Report & MSBuild [modified] Pin
Ergwun9-Jun-10 21:18
Ergwun9-Jun-10 21:18 
QuestionMemory leak in VB.NET screenshot application Pin
Jordan19826-Oct-09 4:10
Jordan19826-Oct-09 4:10 
AnswerRe: Memory leak in VB.NET screenshot application Pin
Dave Kreskowiak6-Oct-09 4:39
mveDave Kreskowiak6-Oct-09 4:39 
Jordan1982 wrote:

For Each scr As Screen In Screen.AllScreens\
screenSize = New Size(scr.Bounds.Width, scr.Bounds.Height)
screenGrab = New Bitmap(scr.Bounds.Width, scr.Bounds.Height)
g = Graphics.FromImage(screenGrab)
g.CopyFromScreen(a, New Point(0, 0), screenSize)
g2.DrawImage(screenGrab, a)
a.X += scr.Bounds.Width
Next
allScreensCapture.Save(strPath, System.Drawing.Imaging.ImageFormat.Jpeg)
g.Dispose()


Since you're creating a Graphics object on every iteration of this loop, you MUST also call its Dispose method on every iteration of the loop. Move the Dispose you have after the end of the loop inside the loop. As it stands now, the only Graphics object that gets disposed is the last one you created. You can also call the Dipose method on any Bitmap objects you create, like that screenGrab.


A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007, 2008
But no longer in 2009...




GeneralRe: Memory leak in VB.NET screenshot application Pin
Jordan19826-Oct-09 5:00
Jordan19826-Oct-09 5:00 
AnswerRe: Memory leak in VB.NET screenshot application Pin
Luc Pattyn6-Oct-09 5:39
sitebuilderLuc Pattyn6-Oct-09 5:39 
Questioncopy functionality does not work in CrystalReportViewer Pin
maryam.saboor6-Oct-09 1:02
professionalmaryam.saboor6-Oct-09 1:02 
QuestionBroken Clipping Region Pin
RichardM15-Oct-09 15:26
RichardM15-Oct-09 15:26 
QuestionCustom file format - how to let Windows recognize properties like labels? Pin
pimb24-Oct-09 8:45
pimb24-Oct-09 8:45 
AnswerRe: Custom file format - how to let Windows recognize properties like labels? Pin
Richard MacCutchan5-Oct-09 1:01
mveRichard MacCutchan5-Oct-09 1:01 
GeneralRe: Custom file format - how to let Windows recognize properties like labels? Pin
pimb25-Oct-09 5:17
pimb25-Oct-09 5:17 
GeneralRe: Custom file format - how to let Windows recognize properties like labels? Pin
Richard MacCutchan5-Oct-09 6:25
mveRichard MacCutchan5-Oct-09 6:25 
GeneralRe: Custom file format - how to let Windows recognize properties like labels? Pin
pimb25-Oct-09 6:30
pimb25-Oct-09 6:30 
AnswerRe: Custom file format - how to let Windows recognize properties like labels? Pin
Richard MacCutchan5-Oct-09 7:22
mveRichard MacCutchan5-Oct-09 7:22 
GeneralRe: Custom file format - how to let Windows recognize properties like labels? Pin
Richard MacCutchan7-Oct-09 0:49
mveRichard MacCutchan7-Oct-09 0:49 
GeneralRe: Custom file format - how to let Windows recognize properties like labels? Pin
pimb214-Oct-09 2:52
pimb214-Oct-09 2:52 
GeneralRe: Custom file format - how to let Windows recognize properties like labels? Pin
Richard MacCutchan14-Oct-09 3:01
mveRichard MacCutchan14-Oct-09 3:01 
QuestionBindingSource Insert problem .... Pin
devboycpp3-Oct-09 22:19
devboycpp3-Oct-09 22:19 
QuestionWhy does my visual studio 2008 give me an error of "XMAL editor missing" when I try to use designer in WPF Pin
havegunwilltravel3-Oct-09 9:27
havegunwilltravel3-Oct-09 9:27 
AnswerRe: Why does my visual studio 2008 give me an error of "XMAL editor missing" when I try to use designer in WPF Pin
havegunwilltravel3-Oct-09 9:35
havegunwilltravel3-Oct-09 9:35 
AnswerRe: Why does my visual studio 2008 give me an error of "XMAL editor missing" when I try to use designer in WPF Pin
Mark Salsbery3-Oct-09 11:13
Mark Salsbery3-Oct-09 11:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.