Can it be loaded dynamically or on demand?

The Aspose DLL files are quite large, which can slow down the startup time and increase the memory footprint of an application. How can I implement on-demand loading and dynamic loading of specific required functions?
I’m using Aspose.Total for C++, and I only need the compression functionality.

@xingyu11

To implement on-demand and dynamic loading of specific functions in Aspose.Total for C++, you can utilize the FreeLibrary function to unload DLLs that are not needed, which can help reduce memory usage and improve startup time.

Here’s a general approach you can follow:

  1. Load the Required DLLs Dynamically: Use LoadLibrary to load only the DLLs that you need for your application. For example, if you only need the compression functionality, load the specific DLL related to that feature.

  2. Free Unused DLLs: When you are done using a particular functionality, you can call FreeLibrary to unload the DLL. This will help in managing memory more efficiently.

  3. Error Handling: Ensure to handle any exceptions or errors that may arise during the loading and unloading of the libraries to prevent crashes.

Here is a simple code snippet demonstrating how to load and unload a DLL dynamically:

#include <windows.h>
#include <iostream>

int main() {
    HMODULE hModule = LoadLibrary("Aspose.Pdf.Cpp_vc14x64.dll");
    if (hModule) {
        // Call functions from the DLL here

        // When done, free the library
        FreeLibrary(hModule);
        std::cout << "DLL unloaded successfully." << std::endl;
    } else {
        std::cerr << "Failed to load DLL." << std::endl;
    }
    return 0;
}

Make sure to replace "Aspose.Pdf.Cpp_vc14x64.dll" with the actual name of the DLL you need for compression functionality. This approach allows you to manage the loading of libraries based on your application’s requirements, thus optimizing performance.

For further details or specific issues related to dynamic loading, you may want to check the latest updates or discussions in the Aspose forums, as there may be additional insights or solutions shared by other users or the support team.

Sources:
[1]: Total for C++ 20.2 crashed with dynamic loading

Which DLL is required for compression functionality in Aspose.Total for C++?

@xingyu11,

We have Aspose.ZIP API that can compress files to create archives or decompress archives but the library is available for .NET, Java and Python. Could you please provide more details about the compression functionality you require? What file formats are you working with or using?

Thanks for your response.
Need word, PDF, PPT, Excel, but I need C++

@xingyu11,

See the product page to check what C++ libraries are included in the Aspose.Total for C++ package for your reference. You can use Aspose.Words for C++ API to create, convert, and manipulate MS Word processing file formats. Aspose.PDF for C++ can create, manipulate, and render PDF files. You may use Aspose.Cells for C++ to create, convert, render and manipulate MS Excel files. Aspose.Slides for C++ API is used to read, write, and edit PowerPoint presentations and slides in the relevant file formats.

I only need these compression functions of Office. Can they be loaded on demand?

@xingyu11,

Aspose C++ APIs do not provide a feature for loading or unloading library functions on demand, but the approach suggested in the post may be worth trying if it could be helpful for you?

Alternatively, you may try our cloud APIs which are REST based SDKs providing all the capabilities for document generation, conversion and automation platforms.

Are there other ways to reduce the memory usage of an application? For example, how to dynamically load Aspose.Total for C++?

@xingyu11,

I’m afraid there may not be better options (other than the proposed approaches/suggestions) to deal with it in Aspose.Total for C++ APIs. We will still check and if you find some good ways, we will let you know here.