Results 1 to 14 of 14

Thread: Why oh why do vb apps use so much ram?!

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    Why oh why do vb apps use so much ram?!

    I have a form, borderstyle set to none, dimensions 5 pixels by 5, visiible = false, and it STILL uses 2mb+ of ram..

    how can you get it to use less ram? for example, if i want no form at all, just an icon in the tray which will contain code, how can i do this?

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I guess becuase it is loading the vb runtime into memory also.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    to have no form, just put your code in your main in a module!

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    VB uses COM, which needs to allocate space for itself. In my experience, initializing COM in a simple C++ app causes about 1.5 - 2 MB of extra RAM to used.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    when i added a module, removed the form, and used a module with submain and the code "msgbox test" - and this used 3.5 megs of ram. then i set it to do nothing.. and it used 2mb+ of ram in the fraction of a second it was open..

    arrgh how can you stop it from using so much ram?!

  6. #6
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    What kind of computer are you running this program on that 2mb of ram is a lot?!!? Even when I had windows 3.1, I still ran with 64mb of ram, and 2 mb isn't much out of 64. Most people have 128 or 192 now-a-days.
    <removed by admin>

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    still.. i saw a MUCH better trayer program than the one i had created (the one to add apps to the tray) which was written in c++, took up 127k of ram and was using subclassing and everything.. i just want to know how i can build a vb app which does something like that and take <1 meg of ram to accomplish..

  8. #8
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    It's gotta be something to do with the VB runtimes or the way VB works. 2 MB sounds like the minimum amount of memory a VB program will use.
    <removed by admin>

  9. #9
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    I just looked and I have a program called CounterAmp that I made in VB, but I didn't use any controls, it is all drawn with code, and it only takes 1.7mb of RAM. That's still a lot, but compared to programs like internet explorer that take 10+ megs, it's not that much.
    <removed by admin>

  10. #10
    hellswraith
    Guest
    Are you running it in the IDE? If so your running with p-code.

    Did you compile to native code, or p-code? If you compile to p-code, the runtime is most definitely loaded because it acts as a interpreter. Native code is usually a little better in the ram department because it uses the runtime as a "true" dll file, not as an interpreter also.

    I can't give you numbers, as i am not on a VB enabled machine right now. Try compiling it to native code, and running it outside of the ide, see if that improves performance.

  11. #11
    jim mcnamara
    Guest
    I didn't read the other posts - mea culpa.

    But - did you know that VB runs inside a virtual machine, just like java? The virtual machine takes up RAM, even with a zero size program (if there could be such a thing).

    Every form, every control, every object you reference requires that the OS map memory into your process space to handle it.
    You put 20 textboxes on a form and watch it crash....

  12. #12
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Does native code run in a VM, or just P-code? I was under the impression that native code calls functions from the vb runtime dll like like any Win32 program would call functions from any standard dll.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  13. #13
    hellswraith
    Guest
    Josh T,
    Look at my earlier reply in this thread....or.....the short answer, you have it right....

  14. #14
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Also, turning off the option 'incremental building' can save alot of space.

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