CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2007
    Posts
    28

    computer sluggish after application

    I am writing an application that searches data and writes it to a text file. All this is done through looping, many times through 150,000 data items.
    After the application ends my computer becomes sluggish and stays that way. I have tweaked the registry to "AlwaysUnloadDlls", thinking the dlls used by the application is hanging around to long. this has not worked. Anyone have any ideas to stop the sluggishness?

  2. #2
    Join Date
    Oct 2003
    Location
    Merate-North Italy
    Posts
    230

    Re: computer sluggish after application

    Try to open Task Manager and check if the application is still inside the running processes. Also try check if your file size is too excessive.
    ++++++++[>++++++++<-]>+.<+++[>++++<-]>+.<++[>-----<-]>.<+++[>++++<-]>++.<+++[>----<-]>-.----.
    God does not play dice with the universe.(A.Einstein)

  3. #3
    Join Date
    Jan 2007
    Posts
    28

    Re: computer sluggish after application

    The file size ends up 12 megabites. But that's outside the application.

  4. #4
    Join Date
    Oct 2003
    Location
    Merate-North Italy
    Posts
    230

    Re: computer sluggish after application

    And what about the CPU usage in task manager? You can also sort your processes by CPU in the task list. What process is slowing your PC?
    ++++++++[>++++++++<-]>+.<+++[>++++<-]>+.<++[>-----<-]>.<+++[>++++<-]>++.<+++[>----<-]>-.----.
    God does not play dice with the universe.(A.Einstein)

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: computer sluggish after application

    Also as a iterest sake.. how are you terminating the application.. are you wrapping up all the Dll's properly, and exiting in a orderly fasion... (not with a END statement..

    Gremmy..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  6. #6
    Join Date
    Jan 2007
    Posts
    28

    Re: computer sluggish after application

    Andrea Rossini was on the right track (file size). It wasn't the physical file size but the the string array size I was using to access the file. Since the file was changing during a looping, I didn't know the string array size so I was doing a lot of redimming. Example under option explicit I used:

    Dim strA()
    Dim a as long

    I used Redim strA(a) everytime a changed. This is what created the sluggishness after I closed the program. So I changed to

    Dim strA(800000)

    since strA could get quite large, but not 800000 large, but wanted to see if it would accept a large array. It did and I didn't need to Redim. Not only did the sluggishness stop, but the loop speeded up from taking nearly four and a half minutes to complete, to taking 30 seconds.

    It's amazing how on this furom you may not get the exact answer, but someone has a suggestion that leads to an answer. Thanks everyone

  7. #7
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: computer sluggish after application

    That's great... Glad you got a problem sorted, but what still gets me a little confused, is why when the application ended, the sluggishness remained. After all when the app exit's it realeases all memory used, including memory from all the redimmed variables...

    In essence when a application terminates it should leave the system in exactly the same state as before it started (Excluding system Services applications).. It is obvious that your application is leaving a residule effect behind, which it shouldn't.. (and i'm not talking about files written to the HDD)..

    In all honesty you've found something to increase the efficiency of the application, Including memory usage, but you have not found out why you have a residule effect...

    I'd still look ito why the application is not terminating properly, as this may cause problems in future..

    Gremmy...
    Last edited by GremlinSA; May 10th, 2007 at 08:48 AM. Reason: typo's
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: computer sluggish after application

    It makes sense not to redim constantly, as VB creates TWO string copies when you REDIM a string.

    I agree with Gremmy, that you have a memory leak. That should be the first thing to fix.

    Generally it's good to step thru your exit routine to see what is and isn't closing.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Jan 2007
    Posts
    28

    Re: computer sluggish after application

    Seems like everything is unloading, but I do have at unload the freelibrary
    function. This is because my program has a related document .res file that allows me to have xp visual styles with vb6 and needs to be freed at unload or I get an error message. Wonder if this is the problem. How does one check for memory leak anyways.

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

Featured