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

    ending program takes 5 minutes

    I have made an application in VB that reads about 30000 records from several databases. These records are stored as objects in VB. The problem is that when I try to end the program, this takes several minutes. During this shutdown my harddrive is constantly being accessed. All references to objects are allways set to Nothing, and I have also tried to abruptly end the program using the End statement, but this only makes it worse.

    If I kill the program in the Process viewer util the program stops immedately, also if the program is allready in the shutdown process.
    If I try to end the program using the Windows task manager, the program first tries to shutdown nicely, then the task manager starts complaining that the program is not responding. I can then stop the program by clicking End task without waiting for the program to respond.

    Is there any way to abruptly stop a program in VB? I then first close all database connections etc. and then want to kill the process as this is basically what I do using the process viewer.


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: ending program takes 5 minutes

    "about 30000 records from several databases"
    Now, it may be time to shut down is related to time to close all those databases
    to test this, once you're sure you have closed all them from vb, wait for 5 minutes, then close your program again. Any difference?
    If so, it will not help you to kill vb program. You should be look for a different way to open/read from those several databases (I imagine at least one of those readings retrieve more records than you suspect...)

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    May 2001
    Posts
    4

    Re: ending program takes 5 minutes


    Thanks for the suggestion!

    I have tried to close the databases and then waiting before proceeding with the shutdown process, but it did not help. And all the records being read are really needed for the program...

    The problem is most probably related to the amount of objects loaded, because I also have some smaller test databases with in total about 8000 records, and this works fine...


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: ending program takes 5 minutes

    ...as objects? Are you dinamically loading 30.000 objects? Can't you use array of objects of same type?


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: ending program takes 5 minutes

    Why not use the recordset and load the data in an object if needed?

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  6. #6
    Join Date
    May 2001
    Posts
    4

    Re: ending program takes 5 minutes


    The recordsets contain quite a lot of grouping data meaning that using the recordsets directly without translating them into objects would be:
    1: Quite difficult to reorganize the data (sometimes needed)
    2: Extremely slow compared to the current solution using direct references to the objects (user clicks a record, and a reference to the object is immedately known. Using the recordsets would need quite a lot of search work)

    What I really need is some way of efficently cleaning up the objects...


  7. #7
    Join Date
    May 2001
    Posts
    4

    Re: ending program takes 5 minutes


    The objects are referenced through several variables in the program. Using arrays these references could be replaced by indices in the arrays, but I would then get problems when deleting records from the arrays. Either I would have to make some kind of special value indicating the element has been deleted or I would have to move the rest of the elements of the array, redim the array and update all the indices.
    Because the user can add, modify and delete records with the program the storage must be dynamical.

    I also just made a small test program containing one array of some simple class. Filling this array with 30000 instances worked fine, 50000 worked ok, 70000 started to show problems and 100000 almost crashed my computer...


  8. #8
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: ending program takes 5 minutes

    As I am not used to this - but it seems interesting - may you provide a small example?
    Thanks.

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  9. #9
    Join Date
    May 2001
    Location
    London
    Posts
    4

    Re: ending program takes 5 minutes

    Why are you creating objects for every record in the recordset - in an array or otherwise? Surely, the user will only be processing (insert/amend/delete) one record at a time. Why not create the application specific objects only for the record being processed and let the recordset object itself act as the container for the bulk of the data?


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