Results 1 to 9 of 9

Thread: Tips for reducing memory usage??

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Hi. I am just wondering if some of you experienced programmers could leave some general tips on how to reduce the amount of memory an application uses. Some of my programs use way too much memory and I even got an 'out of memory' error today when unloading the application.

    Thanks

    Wengang

    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    1. Try to avoid Controls and objects as much as possible, use UDT's instead of classmodules.
    2. Don't have unnessesary variables, Use arrays instead of collections, Erase or optimize arrays that you don't need/have items you don't need
    3. Don't use End, don't declare objects in standard modules without unloading them before termination
    4. Don't terminate your app! That means don't click the stop button on vb toolbar
    5. Be careful and delete all objects and device context when youre dealing with api's
    6. Have resource meter loaded, and watch what's causing the resource loss.

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    Thanks Kedaman

    Question:
    If I declare a variable array like this

    dim strVariable(10000) as string

    Does that set aside memory for 10001 variables right away,
    or just one, or does it set aside memory only as they are
    assigned values?

    And if that is the case (the first one), when you are coding, do you regularly use any method of releasing the memory space of the unassigned strings?

    Thanks again.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    the array will take up 24 bytes + the cumulative string lengths*2 + 22*10000 bytes

    declare the array dynamic and you'll be able to erase it with erase statement =

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Addicted Member LAURENS's Avatar
    Join Date
    Jan 2000
    Location
    Utrecht, the Netherlands
    Posts
    138

    Question What's a UDT?

    This may sound stupid to you, but what is a UDT? User Defined Type?

    Regards,
    Laurens

    Using VB5 Enterprise edition SP3
    VB6 Enterprise edition SP5

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    yep, User Defined Type
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Kedaman,
    You said "Have resource meter loaded...".
    What is that and where can I get it from?

    Thanks.
    Thanks

    Tomexx.

  8. #8
    New Member
    Join Date
    Oct 2000
    Location
    Bangalore
    Posts
    9

    Thumbs up

    Resource meter means the application which gives u all the details 'bout ur system dynamically. Like memory usage currently, cpu usage.

    U can find this option under ur program- accessories- system tools option under win9x for WinNT, u have to just press Cltr + Alt + Del and go to performance tag.

    Thats it.

    Cheers
    Latesh

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Sorry, i was away this weekend and that last post was posted 2 mintues before my bus. Yep Resource meter should be at
    C:\WINDOWS\RSRCMTR.EXE
    but it only shows System, GDI and User Resources, but that's the ones you need to keep looking at while your running your app.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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