What is Taking Up So Many Resources?

Posted on 2005-04-21
Last Modified: 2011-08-18

My program, a quite simple program, uses so many resources it's incredible. And it varies a lot, sometimes it takes about 15,000 K, sometimes it reports 25,000K in the task manager. Why is this? All I use is simple variables, a couple of arrays with like 10,000 entries.., a few BMP's including one that's 150 x 150, no big deal!...

I know it would be easier if you could see the code but let's just make it a general question then. What, in general, does take a lot of system resources? I have many hytpothesis but no clue:

- graphics?
- arrays?
- variants instead of fixed type variables?
- ongoing processes like Timers (I have like 8 firing every second, could this be that?)

Please don't tell me the usual stuff like "using an image object takes up less resources than a picture object", I know that. Or don't answer "all of these things take up resources". I know that. I know that using variant is not as good as fixed type varialbles, but what I really need to know is what, in general, TAKES THE MOST RESOURCES so I know where to look first... what to fix prioritarily.

Thanks a ton,


Question by:GizmoBlaster
    LVL 23

    Accepted Solution

    I would have to say from what you have explained the Timers ( the on going processes ) would take up the most resources. Have you got any loops within the timers ie for ... next, do until, etc ?

    You said you have a few graphics so I would put that as last in the list of things that take up the most resources, unless your defintion of a few is like a few hundred or a few thousand or something to that extent then obviously that would mean it would take up more resources ( obviously ).

    Other then that I would look at the arrays as you said you had aprox 10,000 or so and also using fixed typed variables.

    I am not really sure other then that what kind of an answer you were hoping for !!

    If this is not sufficient please let us know :)
    LVL 29

    Assisted Solution

    I don't think its the timers at all, it might be the code you have inside the timers but the timers alone are great for  keeping low system resources.

    If you have loops in your timers make sure you exit the loops and add Doevents to let the system catch up.

    Please post the code you have inside the timers.
    LVL 1

    Assisted Solution

    What is your definition of "resources"? Do you mean memory? Or CPU processor power? Or generated page faults? What does Task Manager say while your program is running, first upon startup, then after a few minutes? Is this in the VB IDE or after you have compiled your project? Are you compiling to native code or to p-code? P-code is much smaller on disk, but generally runs a bit slower due to lack of optimizations (among other things).

    We need more info before we can give you a solid answer.

    Author Comment

    When I talked about arrays of 10,000, I meant I have 2-3 arrays with dimensioned for 10,000 entries but they are not used up. mostly 100 entries per array most of the time. short text entries I mean.

    by resources, I meant memory. Just found out that it only doubles when my app invokes windows media object, then it passes from approx 13,000 K to 25-30,000K... So that partly answer my question. But still, 13,000K seems a lot for a simple app, how come my app is requesting so much memory from windows? What kind of thing lock in memory from windows like that? That's what I don't understand.

    LVL 29

    Assisted Solution

    If you post your code so everyone can look at it, it might help.  Try disabling each timer 1 by 1 and check to see if the memory goes down at all, if it goes down by alot then I would overlook the code in that timer.

    Without posting your code it's really a guessing game.
    LVL 1

    Assisted Solution

    Agreed. It is a guessing game. Remember, every variable type takes up a different amount of memory, with variants taking a whopping 8 bytes per element in an array, plus overhead. This is from memory, but I think that's accurate. So, again, without code I can only guess, but you might not be specifying a type with your array dimensions, which means the default type is Variant. If you don't need that many, try using ReDim Preserve array_name(# of elements) to cut down on allocated memory. This is a slow process (relatively speaking) so you won't want to do it all the time, say in a loop...memory moves are very expensive in VB (and in ASP too).

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now