ModCode/FormCode Memory usage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Philip

    #1

    ModCode/FormCode Memory usage

    Hey All, I've got a Conceptual delema that hopefully someone will have some
    insight on.

    I made a GUI for 1000 fields which are stored in an array of strings to
    programatically retrive them and save them to a file. But I also have 1000
    uniquely named vars (numbers and strings) that I have to assign from the
    String Array. Right now I have one module that declares them all then does
    1000 of the following

    mycustomname = stringarray(1) 'String var
    anothercustomna me = val(stringarray (2)) 'Integer var
    etc..

    My question is concerning the location of this kind of code and how it
    affect memory.

    ->If I move the 1000 asignments to a form that is loaded and unloaded when
    needed is that going to make any difference in the memory usage as oposed to
    just letting it sit in the module?

    I feel that I'm wasting memory because I have more code that generates
    statistics but it is sitting in modules that are called once upon request of
    the user.

    ->If I put these modules into a DLL won't they still be in memory until my
    app closes?

    -> Also, I havn't gotten a big response to creating a DLL in VB, Should I
    use not even bother with a vb dll and learn VC++ if I need one?

    Thanks in Advance,
    -Philip



  • Steve Gerrard

    #2
    Re: ModCode/FormCode Memory usage

    Comments are inline:

    "Philip" <philip@afterap riltax.com> wrote in message
    news:XiCsb.3202 1$n6.30232@nwrd dc03.gnilink.ne t...[color=blue]
    > Hey All, I've got a Conceptual delema that hopefully someone will have[/color]
    some[color=blue]
    > insight on.
    >[/color]
    Comments, yes, insights, maybe...
    [color=blue]
    > I made a GUI for 1000 fields which are stored in an array of strings[/color]
    to[color=blue]
    > programatically retrive them and save them to a file. But I also have[/color]
    1000[color=blue]
    > uniquely named vars (numbers and strings) that I have to assign from[/color]
    the[color=blue]
    > String Array. Right now I have one module that declares them all then[/color]
    does[color=blue]
    > 1000 of the following
    >
    > mycustomname = stringarray(1) 'String var
    > anothercustomna me = val(stringarray (2)) 'Integer var
    > etc..
    >[/color]
    Ouch. Really no other way?
    [color=blue]
    > My question is concerning the location of this kind of code and how[/color]
    it[color=blue]
    > affect memory.
    >
    > ->If I move the 1000 asignments to a form that is loaded and unloaded[/color]
    when[color=blue]
    > needed is that going to make any difference in the memory usage as[/color]
    oposed to[color=blue]
    > just letting it sit in the module?
    >[/color]

    Yes, if the 1000 variables are module level in a form, they will be
    allocated when the form loads, and discarded when it unloads. Same with
    a class module (a form is actually a type of class).
    [color=blue]
    > I feel that I'm wasting memory because I have more code that generates
    > statistics but it is sitting in modules that are called once upon[/color]
    request of[color=blue]
    > the user.
    >
    > ->If I put these modules into a DLL won't they still be in memory[/color]
    until my[color=blue]
    > app closes?
    >[/color]
    Often they are. The OS gets to decide, and may cache the dll, or keep it
    loaded, or page it out if memory is short, or whatever it feels like. It
    basically says "it will be there when you need it, and the rest of the
    time it's none of your business."
    [color=blue]
    > -> Also, I havn't gotten a big response to creating a DLL in VB,[/color]
    Should I[color=blue]
    > use not even bother with a vb dll and learn VC++ if I need one?
    >[/color]
    A VB6 Dll is an ActiveX.dll, which means that the primary means of
    moving data back and forth is through classes. If you like that, they
    work fine, if not, well then not so fine. I don't think you would see
    much performance or memory usage improvement using a dll. The main
    reason for a dll is if you have two programs that need to use the same
    chunk of code. Even then, many VBers would just copy the code into both
    programs, to avoid hassling with dll version issues, etc.
    [color=blue]
    > Thanks in Advance,
    > -Philip
    >
    >
    >[/color]


    Comment

    Working...