Solved

memory problem with shell

Posted on 1998-11-09
3
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Suggested Courses
Course of the Month7 days, 17 hours left to enroll

617 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