Created Date: 19 Jan, 2021 14:07
Last Modified Date: 04 Mar, 2024 12:05


Introduction

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:

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

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

var jawsMako = IJawsMako.create("", "", new CTemporaryStoreParameters(memoryLimit, diskLimit));
C#
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));
JAVA

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().

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;
    }
}
CPP
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;
    }
}
C#