Prev: Posting 60 messages per second to CView locks up UI (animation continues...)
Next: Turning on ClearType for TextOut() ???
From: Peter Olcott on 10 Mar 2010 12:56 I am have built a general purpose bitmap/image handling class and want to add TextOut() capability to this class. To do this I must convert some of my GDI local function variables into GDI object member variables. This means that I must be able to re-use several GDI objects, instead of constructing them and destroying them after a single use. What issues are raised with resource and memory leaks by using CDC and CBitmap objects? How are these issues mitigated?
From: Tom Serface on 10 Mar 2010 13:29 You will have to manage the resources somehow and someplace, but I don't think it matters how or where. I think you get like 5000 GDI resources before they run out and I think that number is shared among programs. Still converting them is no worse that destroying and recreating them, but you'll have to destroy them ultimately at some point, or, if the number is not to arduous you could let them get recovered when the program exits (but I'm not a big fan of that behavior). Tom "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message news:5oWdnfO3M6HKQArWnZ2dnUVZ_jCdnZ2d(a)giganews.com... > I am have built a general purpose bitmap/image handling class and want to > add TextOut() capability to this class. To do this I must convert some of > my GDI local function variables into GDI object member variables. This > means that I must be able to re-use several GDI objects, instead of > constructing them and destroying them after a single use. > > What issues are raised with resource and memory leaks by using CDC and > CBitmap objects? How are these issues mitigated? >
From: Peter Olcott on 10 Mar 2010 14:08 "Tom Serface" <tom(a)camaswood.com> wrote in message news:%23B3xq%23HwKHA.732(a)TK2MSFTNGP06.phx.gbl... > You will have to manage the resources somehow and > someplace, but I don't think it matters how or where. I > think you get like 5000 GDI resources before they run out > and I think that number is shared among programs. Still > converting them is no worse that destroying and recreating > them, but you'll have to destroy them ultimately at some > point, or, if the number is not to arduous you could let > them get recovered when the program exits (but I'm not a > big fan of that behavior). > > Tom The main thing that I want to do is to manually free any memory or resources that the CBitmap object is using. I don't know what resources it is using, and I don't know how to free them. > > "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message > news:5oWdnfO3M6HKQArWnZ2dnUVZ_jCdnZ2d(a)giganews.com... >> I am have built a general purpose bitmap/image handling >> class and want to add TextOut() capability to this class. >> To do this I must convert some of my GDI local function >> variables into GDI object member variables. This means >> that I must be able to re-use several GDI objects, >> instead of constructing them and destroying them after a >> single use. >> >> What issues are raised with resource and memory leaks by >> using CDC and CBitmap objects? How are these issues >> mitigated? >>
From: Peter Olcott on 10 Mar 2010 14:14 "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message news:WeWdnco19NaPcwrWnZ2dnUVZ_g2dnZ2d(a)giganews.com... > > "Tom Serface" <tom(a)camaswood.com> wrote in message > news:%23B3xq%23HwKHA.732(a)TK2MSFTNGP06.phx.gbl... >> You will have to manage the resources somehow and >> someplace, but I don't think it matters how or where. I >> think you get like 5000 GDI resources before they run out >> and I think that number is shared among programs. Still >> converting them is no worse that destroying and >> recreating them, but you'll have to destroy them >> ultimately at some point, or, if the number is not to >> arduous you could let them get recovered when the program >> exits (but I'm not a big fan of that behavior). >> >> Tom > > The main thing that I want to do is to manually free any > memory or resources that the CBitmap object is using. I > don't know what resources it is using, and I don't know > how to free them. > I think that I got it: Simply call the inherited member DeleteObject(). >> >> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message >> news:5oWdnfO3M6HKQArWnZ2dnUVZ_jCdnZ2d(a)giganews.com... >>> I am have built a general purpose bitmap/image handling >>> class and want to add TextOut() capability to this >>> class. To do this I must convert some of my GDI local >>> function variables into GDI object member variables. >>> This means that I must be able to re-use several GDI >>> objects, instead of constructing them and destroying >>> them after a single use. >>> >>> What issues are raised with resource and memory leaks by >>> using CDC and CBitmap objects? How are these issues >>> mitigated? >>> > >
From: Tom Serface on 10 Mar 2010 17:29 Yeah, that's it... Lots of time people forget to call that. I turn on the GDI Objects column in Task Manager so I can watch what my program is doing. Tom "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message news:H8mdnSY2XczicgrWnZ2dnUVZ_hWdnZ2d(a)giganews.com... > > "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message > news:WeWdnco19NaPcwrWnZ2dnUVZ_g2dnZ2d(a)giganews.com... >> >> "Tom Serface" <tom(a)camaswood.com> wrote in message >> news:%23B3xq%23HwKHA.732(a)TK2MSFTNGP06.phx.gbl... >>> You will have to manage the resources somehow and someplace, but I don't >>> think it matters how or where. I think you get like 5000 GDI resources >>> before they run out and I think that number is shared among programs. >>> Still converting them is no worse that destroying and recreating them, >>> but you'll have to destroy them ultimately at some point, or, if the >>> number is not to arduous you could let them get recovered when the >>> program exits (but I'm not a big fan of that behavior). >>> >>> Tom >> >> The main thing that I want to do is to manually free any memory or >> resources that the CBitmap object is using. I don't know what resources >> it is using, and I don't know how to free them. >> > > I think that I got it: Simply call the inherited member DeleteObject(). > >>> >>> "Peter Olcott" <NoSpam(a)OCR4Screen.com> wrote in message >>> news:5oWdnfO3M6HKQArWnZ2dnUVZ_jCdnZ2d(a)giganews.com... >>>> I am have built a general purpose bitmap/image handling class and want >>>> to add TextOut() capability to this class. To do this I must convert >>>> some of my GDI local function variables into GDI object member >>>> variables. This means that I must be able to re-use several GDI >>>> objects, instead of constructing them and destroying them after a >>>> single use. >>>> >>>> What issues are raised with resource and memory leaks by using CDC and >>>> CBitmap objects? How are these issues mitigated? >>>> >> >> > >
|
Next
|
Last
Pages: 1 2 3 4 5 6 7 Prev: Posting 60 messages per second to CView locks up UI (animation continues...) Next: Turning on ClearType for TextOut() ??? |