Results 1 to 6 of 6

Thread: Free memory

  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Free memory

    Hi everybody,

    From VBA I call a couple of functions from a DLL written in C++.
    This DLL also contains a (hidden) function with a private variable.

    The functions from the DLL are declared in VBA and a call them using the aliases defined in the declare.
    After calling the functions the private variable is set and will keep it's value.

    Because I just call the function, no object is defined in VBA. In memory there will be an object defined (containing the value of the private variable for instance).

    Is there a way to free that memory from VBA code?
    I can not set the object to nothing, because I do not have the object in VB, I just call the function!

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Free memory

    I am a little unclear what you want. Do you want to unload the dll from memory? or just set the value of the variable to it's default?
    What is the variable? In other words is it a real problem? An int takes very little space up. A 10MB Bitmap is very different and then I understand your desire to remove it.
    Can you recode the dll? By that if it is a real memory hogging variable have it as a pointer in the dll and use new and delete to create/destroy the real hog when it is required.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Free memory

    Hi Andy,

    Thanks for the reaction.
    Unloading the DLL is no option, then I have to reload it again about 50.000 times.
    I just want to reset the static.
    I solved it the moment by adding a new function to the dll, initiate.
    There must be a better way, once I will find it.....

  4. #4
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Free memory

    Hi Bart,

    How about calling the function with a flag to re-initialise the variable eg. CallFunction(ResetVariableToDefault) and test 'ResetVariableToDefault' inside the dll.

    Out of interest why do you want a static variable in the dll? I've made a number of dll's that are called from Access, maybe you know something I should know.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Free memory

    Hi Andy,

    Queriosity is a great quality, you can learn a lot...
    I put several function in the DLL, which are called in quite a complex batch process from VB. I use some statics to store data in the DLL that is not needed in VB. Working like this prevents sending that data from the DLL to VB and back without using it in VB.
    Because the batch proces is processing a lot of transactions it is no option to remove the DLL from memory and bringing it up again for each transaction.
    And yes, I already programmed an initialise function in the DLL, I did not see another way (although I still think there must be one).

    Thanks for the help.

  6. #6
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Free memory

    I guessed that was the reason for the static. I'd do a very similar thing as I can't think of another other viable method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •