Skip to main content
Skip table of contents

Adjusting resources allocated to Jaws

Introduction

Every Mako project starts with creating an instance of the IJawsMako object, from which all other Mako classes are derived. The parameters are described in the API documentation, and reproduced here. Examples of using this API in code are given below.

create()

static JAWSMAKO_API IJawsMakoPtr JawsMako::IJawsMako::create

(const U8String & tempDir = U8String(""),

const U8String & cacheDir = U8String(""),

const CTemporaryStoreParameters & tempStoreParams = CTemporaryStoreParameters(),

const std::map< std::string, std::string > & initialParams = std::map< std::string, std::string >())

static

Create an IJawsMako instance.
Only one may be created at any one time.

Parameters

tempDir

An absolute path to a directory that JawsMako can use to store temporary files. If a non-empty string is passed, the directory must exist. If an empty string is passed, JawsMako will choose an appropriate temporary location based on the host operating system.

cacheDir

An absolute path to a directory where JawsMako may persistently store cached information. If an empty string is passed, JawsMako will choose an appropriate location based on the host operating system. If a directory is passed, it must exist.

tempStoreParams

The desired temporary store parameters. See CTemporaryStoreParams for details.

initialParams

The set of initial parameters for the JawsMako instance. Currently, this is used for licensing.

Returns

IJawsMakoPtr A smart pointer to the new instance.

Code examples

Mako uses sensible defaults for memory and disk allocation to the Jaws instance that it uses for PDF input, rendering, and PostScript output that works for ~99% of cases. Should an out-of-memory error occur, it may be necessary to adjust these values. The following code snippet shows how this is done:

CPP
uint64 memoryLimit = 8ULL * 1024ULL * 1024ULL * 1024ULL; // 8GB Memory
uint64 diskLimit = 100ULL * 1024ULL * 1024ULL * 1024ULL; // 100GB Disk

IJawsMakoPtr jawsMako = IJawsMako::create("", "", CTemporaryStoreParameters(memoryLimit, diskLimit));
C#
var memoryLimit = 8UL * 1024UL * 1024UL * 1024UL; // 8GB Memory
var diskLimit = 100UL * 1024UL * 1024UL * 1024UL; // 100GB Disk

var jawsMako = IJawsMako.create("", "", new CTemporaryStoreParameters(memoryLimit, diskLimit));
JAVA
var memoryLimit = BigInteger.valueOf(8 * 1024 * 1024 * (long)1024); // 8GB Memory
var diskLimit = BigInteger.valueOf(100 * 1024 * 1024 * (long)1024); // 100GB Disk
        
jawsMako = IJawsMako.create("", "", new CTemporaryStoreParameters(memoryLimit, diskLimit));

Detecting when temporary storage has been exhausted

A flag is set when temporary storage has been exhausted. These code examples show it being used in a catch{} block. The flag can be reset with clearExhaustedFlag().

Click here to expand this C++ example
CPP
int wmain(int argc, wchar_t* argv[])
{
    IJawsMakoPtr jawsMako;
	try
    {
        // Create JawsMako instance
        const uint64 memoryLimit = 8ULL * 1024ULL * 1024ULL * 1024ULL; // 8GB Memory
        const uint64 diskLimit = 100ULL * 1024ULL * 1024ULL * 1024ULL; // 100GB Disk
        jawsMako = IJawsMako::create("", "", CTemporaryStoreParameters(memoryLimit, diskLimit));
        IJawsMako::enableAllFeatures(jawsMako);

        ...

        return 0;
    }
    catch (IError& e)
    {
        if (jawsMako->getTempStore()->getWasExhausted())
            std::wcerr << L"Temporary storage was exhausted." << std::endl;
        const String errorFormatString = getEDLErrorString(e.getErrorCode());
        std::wcerr << L"Exception thrown: " << e.getErrorDescription(errorFormatString) << std::endl;
        return e.getErrorCode();
    }
    catch (std::exception& e)
    {
        std::wcerr << L"std::exception thrown: " << e.what() << std::endl;
        return 1;
    }
}
Click here to expand this C# example
C#
class Program
{
    static int Main(string[] args)
    {
        var jawsMako;
        try
        {
            // Create JawsMako instance.
            var memoryLimit = 8UL * 1024UL * 1024UL * 1024UL; // 8GB Memory
            var diskLimit = 100UL * 1024UL * 1024UL * 1024UL; // 100GB Disk
            jawsMako = IJawsMako.create("", "", new CTemporaryStoreParameters(memoryLimit, diskLimit));
            IJawsMako.enableAllFeatures(jawsMako);

            ...

        }
        catch (MakoException e)
        {
            if (jawsMako.getTempStore().getWasExhausted())
                Console.WriteLine("Temporary storage was exhausted.");
            String errorFormatString = getEDLErrorString(e.m_errorCode);
            Console.WriteLine ("Exception thrown: " +  e.m_msg);
            return 1;
        }
        catch (Exception e)
        {
            Console.WriteLine($"Exception thrown: {e}");
        }

        return 0;
    }
}


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.