🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: microsoft.public.vb.bugs
2 messages
2 total messages Started by Martin E. Muehlmann Wed, 29 Aug 2001 05:01
memory leak using VBA6 and file access
#4
Author: Martin E. Muehlmann
Date: Wed, 29 Aug 2001 05:01
35 lines
2877 bytes
Hi!

I have a VBA 6 application (hosted in Excel, Win 2000 prof + SP 2 and SP5
for VStudio 6) and for some reasons I have a communication using files
between this app and a C program (that is a shelled process of my VBA app).
I know that this isn't the most elegant method of exchanging data but that's
how it is and I want to ask YOU before I redesign it from scratch.

loop 20000 times:
    1. VBA app writes textfile w/ data. (sequential mode)
    2. C program reads it and processes data
    3. C program writes output textfile
    4. VBA app read output file (sequential and binary mode)
next

The problem is that I call this C program tousends of times and after each
iteration I have less free resources and after a couple of hours the system
crashes and  I can't even open a textfile. The curious thing is that the
task manager tells me that the Excel process allocates only about 25kBytes
(and this doesn't change while my app is running...)

I'm quite sure that it is not the C program itself which causes the crash,
but the type of communication I've chosen. I even recoded the file access
from sequential mode to binary mode (only for reading the data not for
writing them though).

Has anybody experienced similar problems and do you have a solution for
that?

Thank you for reading my posting,
Martin

PS: Ich versteh auch Deutsch und ich hoff du verstehst mein Englisch *g*.

martin@ece.mcgill.ca
Re: memory leak using VBA6 and file access
#5
Author: Dev Ashish
Date: Wed, 29 Aug 2001 12:35
29 lines
2526 bytes
[ followup set to microsoft.public.office.developer.vba ]

Martin E. Muehlmann wrote:

> loop 20000 times:
>     1. VBA app writes textfile w/ data. (sequential mode)
>     2. C program reads it and processes data
>     3. C program writes output textfile
>     4. VBA app read output file (sequential and binary mode)
> next
> 
> The problem is that I call this C program tousends of times and after
> each iteration I have less free resources.

If you are really sure that the C program is not causing the leaks, then 
you'll have to post your VBA code (that does the above) before anyone here 
can offer suggestions. It could be as simple as you not closing the shelled 
instances (which might be open in hidden mode), or it could be a lang. bug 
(doubt it).

As for the redesign, it really depends on what you are trying to do.  
Depending on the data size & type, and if you are the author of the C app, 
you could try switching to calling stdcall convention functions from VBA 
(which probably would be the fastest way).  You could also use memory mapped 
files and passing the pointers back and forth. As you can see, chances of 
you causing leaks increase as you step away from the VBA layer. I would 
definitely reconsider the file IO data exchange method though, FWIW.

  -- Dev
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads