Results 1 to 12 of 12

Thread: [RESOLVED] DC performance

  1. #1

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Resolved [RESOLVED] DC performance

    Hai all,

    i have a timer with 1 interval and it keep bitblt'ing screen in to a memory dc.
    my question is,

    do i need to create and delete the memory dc on each interval or better i i create the dc at form load and keep bitblt on to it and delete it on forum unload.


  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: DC performance

    2nd option seems better
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DC performance

    Hai pradeep,
    Thanks for the answer.
    let me see few other openions also

  4. #4

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DC performance

    pradeep, ar you sure the second option is the best solution?
    if i tried, out of memory occours

  5. #5
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: DC performance

    Fazi show us your code, It sounds like you might be forgetting to destroy some GDI objects.

    Like PraDeep, I would keep the DC and the Bitmap alive for the duration, but at the end of the day I don't think there is much in it either way.

  6. #6

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DC performance

    Milk, seems yes,
    let me check it then.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: DC performance

    Quote Originally Posted by Milk
    Fazi show us your code, It sounds like you might be forgetting to destroy some GDI objects.

    Like PraDeep, I would keep the DC and the Bitmap alive for the duration, but at the end of the day I don't think there is much in it either way.
    Agreed as long as we are only talking about a couple of DCs. Where people go overboard is when they have like 100 images and also have 100 DCs -- waste of resources when only a one or two DCs are needed at any one time; sometimes a few more depending on situations.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: DC performance

    yes milky, your correct.
    GetDc has been called on every second and not released. a lam bug.

    now i put it to form load as you and predeep suggessed earlier to keep it though out the session and distroyed at the unload of form.


  9. #9
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: DC performance

    Quote Originally Posted by LaVolpe
    Where people go overboard is when they have like 100 images and also have 100 DCs
    Yes, and from the top of my head the most I could conceive using would be 3.

    Fazi, is your timer running at interval 1 or 1000?

  10. #10

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: [RESOLVED] DC performance

    1 and now made it to 100 y milk?

  11. #11
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: [RESOLVED] DC performance

    Only because I thought you meant 1 and then you mentioned a second which would tip the balance for me making me more inclined to create the DC each time, basically because it would be just sitting there doing nothing for 99% of the time. It's much of a muchness anyway.

    Good luck with your prog

  12. #12

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: [RESOLVED] DC performance

    yah it was just 1 ms only. now it is 100 ms,

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width