×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

IB server is taking too many resources!

IB server is taking too many resources!

IB server is taking too many resources!

(OP)
Hey Everyone

I've created a program that rebuilds a corrupt database. The program works perfectly but when the rebuild has completed, I press alt-ctrl-del, and find that IBServer is utilising over 100MB of resources, this causes the system to be very sluggish. If I disable the server in control panel and then restart it, my problem is solved, but I'd like the process to be more automatic. Is it possible to restart the IBserver programatically in Delphi. Any suggestions would be helpful!

Thanks!

RE: IB server is taking too many resources!

Not sure if this is the correct approach to solving problem (maybe better to see why its consuming so much resources in the first place) but here is some code to start the Interbase Service programitically :


*  S t a r t S e r v e r ( )
*
****************************************************************
*  Author: The Client Server Factory Inc.
*  Date:   March 1, 1999
*
*  Input:
*
*  Return:
*
*  Description:
*
*****************************************************************
* Revisions:
*
*****************************************************************}
Function StartServer(): boolean;
Var
  lRegistry: TRegistry;
  lStartUpInfo: STARTUPINFO;
  lSecurityAttr: SECURITY_ATTRIBUTES;
  lProcessInfo: PROCESS_INFORMATION;
  lEXEName: String;
  lArray: Array[0..255] Of char;
Begin
  result := False;
  lRegistry := TRegistry.Create;
  Try
    Screen.Cursor := crHourglass;
    lRegistry.RootKey := HKEY_LOCAL_MACHINE;
    If Not lRegistry.OpenKey('Software\Borland\InterBase\CurrentVersion',
False) Then
      ShowMessage('InterBase server is not installed on your system.')
    Else
      lEXEName := Format('%s%s -a', [lRegistry.ReadString('RootDirectory'),
        'bin\ibserver.exe']);
    ZeroMemory(@lStartUpInfo, SizeOf(lStartUpInfo));
    lStartUpInfo.cb := SizeOf(lStartUpInfo);
    lSecurityAttr.nLength := SizeOf(lSecurityAttr);
    lSecurityAttr.lpSecurityDescriptor := Nil;
    lSecurityAttr.bInheritHandle := True;
    If CreateProcess(Nil, StrPCopy(lArray, lEXEName), @lSecurityAttr, Nil,
      False, 0, Nil,
      Nil, lStartUpInfo, lProcessInfo) <> Null Then
      result := True
    Else
      ShowMessage('The server could not be started.')
  Finally
    lRegistry.Free;
    Screen.Cursor := crDefault;
  End;
End;

And just 2 other code snippets that may be useful :

*  StopService ( )
*
****************************************************************
*  Author: Unknown
*  Date:   Sept 2003
*
*  Input:
*
*  Return: true/False (success)
*
*  Description: Stops a service on Windows XP/NT/2000
*
*****************************************************************}

function ServiceStop(aMachine,aServiceName : string ) : boolean;
// aMachine is UNC path or local machine if left empty
var
  h_manager,h_svc   : SC_Handle;
  svc_status     : TServiceStatus;
  dwCheckPoint : DWord;
begin
  h_manager:=OpenSCManager(PChar(aMachine),nil,
                           SC_MANAGER_CONNECT);
  if h_manager > 0 then
  begin
    h_svc := OpenService(h_manager,PChar(aServiceName),
                         SERVICE_STOP or SERVICE_QUERY_STATUS);

    if h_svc > 0 then
    begin
      if(ControlService(h_svc,SERVICE_CONTROL_STOP,
                        svc_status))then
      begin
        if(QueryServiceStatus(h_svc,svc_status))then
        begin
          while(SERVICE_STOPPED <> svc_status.dwCurrentState)do
          begin
            dwCheckPoint := svc_status.dwCheckPoint;
            Sleep(svc_status.dwWaitHint);

            if(not QueryServiceStatus(h_svc,svc_status))then
            begin
              // couldn't check status
              break;
            end;

            if(svc_status.dwCheckPoint < dwCheckPoint)then
              break;

          end;
        end;
      end;
      CloseServiceHandle(h_svc);
    end;
    CloseServiceHandle(h_manager);
  end;

  Result := SERVICE_STOPPED = svc_status.dwCurrentState;
end;

Check if service is already running :

Function IsIBRunning(): boolean;
Begin
  If GetWindow(GetDesktopWindow, GW_HWNDNEXT) = FindWindow('IB_Server',
    'InterBase Server') Then
    result := False
  Else
    result := True;
End;

As you may guess, this represents code I have found on this issue and is from various sources. You will need to change as you feel necessary.

Hope this helps..

Opp.



RE: IB server is taking too many resources!

(OP)
Thanks a million!! I'll give it a try. Even if it doesn't prove useful now, I'm sure it'll come in handy in the future!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close