Solved

running code from a dll as a new process

Posted on 2002-06-21
9
165 Views
Last Modified: 2011-09-20
I have two apps:
 - VideoServer - a standalone video survailance app
 - ServerGuard - manages the servers and runs them

the server is always in one location, only the settings for it change for every new instance
the guard also provides a crash-recover mechanism for the server
if the server freezes or terminates unexpectedly the guard has an option to rerun the server
if the server freezes then the guard terminates the servers process !

for now I have the server as an exe
the guard can run as many servers as it 'wants'
so every server takes it's memory toll

I've already built all of the projects in the group with RT packages
that reduced memory consumption of the server from 38 to 22 mb :)
but still if you have 4 cameras running that's almost 100 mb !!!

I'd like to create a dll from it so the core functions would be shared

that's not really a problem
the problem is that I need a process handle for the guard !!
so how could I run some dll code as a separate process ??
if it turns out difficult I'll increase the points
I have about 2000 to spare :)
0
Comment
Question by:Lee_Nover
  • 5
  • 3
9 Comments
 
LVL 2

Accepted Solution

by:
333 earned 200 total points
ID: 7098071
why you need to run some dll code as separate process?
you can put all shared server's code to dll, then make server as small exe that only calls funtions from dll (and maybe handles local variables). so, your guard process still runs and terminates exe and it will have a handle.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7098085
listening . . .
0
 
LVL 12

Author Comment

by:Lee_Nover
ID: 7098132
333 good idea :)
I never thought of it :)
I'll wait a while for other ideas if anyone has any
I'll also try your method for now
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 12

Author Comment

by:Lee_Nover
ID: 7098171
oh .. a typo
that was from 28 to 22 mb memory usage ! :)

hum ... about running such an application where the actuall app stuff is in a dll

should I use:

with Application do
begin
  Initialize;
  CreateMainFormFromDll;
  MainForm.ShowModal;
  Run;
end;


actually I don't even need the application object here
simply:


begin
  CreateMainFormFromDll;
  MainForm.ShowModal;  
end.


or any other method ?
0
 
LVL 2

Expert Comment

by:333
ID: 7098268
question about your app (maybe you won't be able to reduce memory with dll): those 22mb are your exe's size :) or memory allocated to for example video buffers etc.?
if you can share the same buffers along different server instances, then you can reduce memory usage, otherwise you can't. also, if you create the same component (form or whatever) for each instance, this won't reduce memory usage, if you can create component once and it will work with different server instances, then your memory will be reduced.

sometimes you won't get any benefit from using dlls vs exes. the point is, that when you run your exe first time, windows loads exe's code and data segments into memory, when you run second instance of the same exe, code segment isn't loaded into memory, only pointer will be returned to first instance's code. however, any variables and buffers will be created. so the code part of your app is acctualy shared and it's similar to dlls. exeption to this is compressed exes, for example with upx. in this case, each instance's code will be loaded into memory and it will not be shared and this will increase memory usage.
you may benefit from dll if you're able to use shared memory. when you have separate exes, your code is shared, but data - not. using dll is posible to create objects and allocate buffers once and then share them among instances.

so, if the biggest part of memory is allocated to for example video buffers and you can read or write from different instances to the same buffer, go for dll.
0
 
LVL 12

Author Comment

by:Lee_Nover
ID: 7098291
tnx for the info :)
didn't know exes code was shared !
I don't compress the server exactly because of that non-sharing thingie (I knew about that :)
with using RT packages there is also no need to compress them :)

I have some buffers but they can't be shared

I also have lots of helper functions and I was thinking of moving those to a dll
so if I understood you correctly that code would be shared in memory with an exe as well .. or am I wrong ?

the biggest memory eater are the resources I think
using ks theme for 'leet' xp looks :) (the boss wanted that)
which reminds me .. gotta move that into a RT package also :)
0
 
LVL 2

Expert Comment

by:333
ID: 7098330
about code sharing you may read this
http://www.jrsoftware.org/striprlc.php#execomp
not much info but....

well, most of your functions code should be shared (at least i don't know why the should not :)
i don't know what your server does and how it looks, but AFAIK most servers are running as services or console apps or programs with simple hidden windows, to decrease resource consumption. if you're using gui for some administrative tasks (like setting up parameters etc), then you may consider to make this gui as separate exe, with ability to connect to different servers and talk to them using named pipes for example. in this case, your form with lots of funky bitmaps and other resource eaters will be launched only once.
0
 
LVL 12

Author Comment

by:Lee_Nover
ID: 7098355
yes I already separated all of the settings gui and info guis from the main app
they're created dinamically but still in the same app
that should be enough I guess :)

my server is a complete standalone VideoSurvailance app
but I'll split it into parts as needed
0
 
LVL 12

Author Comment

by:Lee_Nover
ID: 7098362
uh .. forgot to say that other forms have to be in the app because they're bound to some datasets in the main form
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 200
Help on project with Soap 10 54
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 34
Dev express lookupcombo 3 28
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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