Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7180001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:15:23+00:00 2026-05-28T17:15:23+00:00

My program have several worker threads that calling a function in a dynamically loaded

  • 0

My program have several worker threads that calling a function in a dynamically loaded DLL file. The performance is slower than calling function in EXE file. My program made using Delphi. I don’t use ShareMM. The function in DLL has many routines to read file into memory. The used calling convention is stdcall. Actually, the speed is very poor!

I have no idea since I just learned about using DLL. So what should I do to optimize the performance/speed of my program/DLL?

Sorry if my question is non sense. I am sure there is nothing wrong with my exe, I just moved my functions into DLL and the performance be slower. Please ignore disk/memory cache factor as I have mentioned the routines of my DLL.

Edited:

This is how my program load the DLL

  DLLHandle := LoadLibrary(pwchar(path));
  if DLLHandle <> 0 then
  @CheckFile := GetProcAddress(DLLHandle, 'CheckFile');

In my worker threads, I always check the function using if Assigned(CheckFile) then then call CheckFile function.

Here illustration of my function

type
TCheckFile = function(const FileName: string; var FileType: WideString) 
: Boolean; stdcall;
var
CheckFile: TCheckFile ;

Now, the code in DLL

function CheckFile(const FileName: string; var FileType: WideString)
  : boolean; stdcall;
var
  testCheckFile: TBla;
begin
  Result := false;
  testCheckFile  := TBla.Create;
  try
    if testCheckFile.DoSomeRoutine(FileName, FileType) then
      Result := true;
  finally
    testCheckFile.Free;
  end;
end;
exports CheckFile;

begin
IsMultiThread := true;
end.

What my DLL do? It plays with TFileStream like convert file to pointer.

I hope there is something wrong with my loading code and the calling code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:15:24+00:00Added an answer on May 28, 2026 at 5:15 pm

    Code that resides in a DLL runs at just the same speed as code that resides in the host executable. It is exceedingly unlikely that moving code to a DLL will result in a discernible drop in performance.

    However, you state in comments to the question that you have also ported from Delphi 2007 to Delphi XE2. That is almost certainly the change that resulted in the performance drop.

    When measuring and comparing performance it is simply crucial to change one thing at a time so that you remove any possibility for confounding factors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program with several worker threads, and a main thread that receives
I have a static class that creates several worker threads in its constructor. If
I have a program that needs several third-party libraries, and at the moment it
I have a python program that opens several urls in seperate tabs in a
I have several different c# worker applications that run various continuous tasks: sending emails
I have several medium sized (1 MB) xml file that I frequently need to
I have a multithreaded openCV program that uses 4 threads to do the following:
I'm working on a java program, and I have several vectors defined and filled
I have a fairly large program written in C. It spans several files, and
I have several somewhat separate programs, that conceptually can fit into a single project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.