Solved

memory problem with shell

Posted on 1998-11-09
3
184 Views
Last Modified: 2010-04-30
Using VB4, I shell to a program lots of times, this works successfully but each time I loop round the shell I seem to lose a bit of memory (about 1k bytes). After about 200 times round the loop the program crashes with a memory problem. I close all files properly and can see the memory being eaten up by means of the GetFreeSpace function. What can I do to make my program run forever ?
0
Comment
Question by:cjf
3 Comments
 

Expert Comment

by:cmihalache
ID: 1443877
When you shell a program, this call dosn't wait until your new process is finished. After 200 shells, you can have 200 instances of your shelled program in the memory. If this is the problem, I can tell you what to do to solve it.
0
 
LVL 3

Accepted Solution

by:
vikiing earned 100 total points
ID: 1443878
SHELL command triggers a "child" process, but it does NOT wait process completion, that is, while second process is running, control goes back to VB to continue it's job.

You can do the following:
a) The process triggered thru SHELL statement must create, upon completion, a unique file (no matter be its contents), let's say, DUMMY.DAT

b) VB program, in order "to wait" process to end, can do:

     Do
          Shell  'Here, upon completion
                 'SHELLed process created DUMMY.DAT
          On Error Resume Next
          Do
             Open "DUMMY.DAT" for input as #99
          Loop while Err<>0
          Close #99 : Kill "DUMMY.DAT"
     Loop

That stuff synchronizes execution of SHELLed process, waiting until it completes before starting a new instance of a SHELL

(Yes, I know it's horrible; but it's the only way I can invent now... :)
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1443879
There is also the ExecCmd method (I don't know if this works under VB4 or not). This version waits for the child to complete before continuing and will prevent your parent from launching a whole bunch of child tasks.

M

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 59
using Access 8 75
vb6 connector to SQL Server 2 37
VBA: Insert New column with specific format type 12 38
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question