Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

memory problem with shell

Posted on 1998-11-09
3
Medium Priority
?
204 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 200 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

718 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