Call us: +1-415-738-4000

BigMemory C++ Client Setup

Get Started

This section includes the basic steps for setting up access to BigMemory from C++ applications.

1: Verify you have the requirements

  • Microsoft Windows Server 2008 R2 (64-bit), or Red Hat Enterprise Linux 6.4 (32-bit or 64-bit)
  • Microsoft Visual Studio 2012 VC110
  • GNU G++ Complier
  • Oracle Java Development Kit 1.6 or higher (Note: With BigMemory Max 4.1.4 and higher, JDK 1.7 is required.)
  • An application server
  • The BigMemory kit. Download and unpack the BigMemory Max kit, which includes Cross-Language Support.
  • Your license key (terracotta-license.key). Save the license key in your BigMemory home directory.

2: Install the BigMemory Client

Install the BigMemory C++ Client by compiling your application with A and B below:

  • A. Include ${BIGMEMORY_HOME}/apis/cpp/include/bigmemory
  • B. Link to one of the following, depending upon whether you are using Linux or Windows:
    • ${BIGMEMORY_HOME}/apis/cpp/linux/x86
    • ${BIGMEMORY_HOME}/apis/cpp/linux/x86_64
    • ${BIGMEMORY_HOME}/apis/cpp/windows/win32
    • ${BIGMEMORY_HOME}/apis/cpp/windows/x64

3: Install the Cross-Language Connector

Create the JVM that will host the BigMemory instance and the CL Connector, and add the following JAR files to the JVM's classpath.

  • ${BIGMEMORY_HOME}/common/lib/bigmemory-<version>.jar
  • ${BIGMEMORY_HOME}/apis/ehcache/lib/ehcache-ee-<version>.jar
  • ${BIGMEMORY_HOME}/apis/ehcache/lib/slf4j-api-<version>.jar
  • ${BIGMEMORY_HOME}/apis/toolkit/lib/terracotta-toolkit-runtime-ee-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/commons-codec-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/commons-lang-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/commons-logging-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/httpclient-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/httpcore-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/libthrift-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/nServer-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/security-core-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/security-keychain-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/server-embedded-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/server-main-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/server-standalone-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/slf4j-jdk14-<version>.jar
  • ${BIGMEMORY_HOME}/server/lib/thrift-java-<version>.jar

Note: In the file names above, <version> is the current version of the JAR.

4: Customize the cross-lang-config.xml file

A sample cross-lang-config.xml file is provided in the config-samples/ directory of the kit. You will need to customize it with the IP address and port where the CL Connector should bind. Below is an example:

<?xml version="1.0"?>
    xsi:schemaLocation=" xplatform.xsd">

  <bind ip="*" port="8199" type="nirvana"/>

  <workers min="10" max="100" />

  <serializer factoryClass="net.sf.ehcache.xplatform.serializer.MyFactory" />

    <keystore location="/path/to/keystore.jks"/>
    <truststore location="/path/to/truststore.jks">


The optional configurations are:

  • The number of worker threads to handle requests.
  • Security information. For more about security, refer to Securing Terracotta Clusters.
  • Serializer factory to be used to bind the CacheSerializer to the caches. MyFactory can implement the default net.sf.ehcache.xplatform.serialization.CacheSerializerFactory. This class is responsible for creating CacheSerializers for each Cache of the CacheManager. For more information, refer to the Serialization page.

5: Customize the ehcache.xml file

A sample ehcache.xml configuration file is provided in the config-samples/ directory of the kit. If you will be using the Terracotta Server Array, you will also need to customize the tc-config.xml file. For more information about these configuration files, refer to Configuring BigMemory Max.

If you will be deploying the CL Connector as an embedded server process in an existing CacheManager, add the EmbeddedXplatformServer class to your ehcache.xml file, with the cfgFile property pointing to the cross-lang-config.xml:

<ehcache name="existingCacheManager">
<cacheManagerEventListenerFactory class="net.sf.ehcache.xplatform.EmbeddedXplatformServer"
<!-- my caches and other ehcache config -->

All the caches of that "existingCacheManager" will now be accessible from all BigMemory Clients. The server's lifecycle will be tied to the CacheManager. It will start as soon as you instantiate the CacheManager using the configuration, and it will shutdown when you use net.sf.ehcache.CacheManager#shutdown.

6: Start the CL Connector

This step is for starting the CL Connector as a standalone server process. If you have deployed the CL Connector as an embedded server process, it will be started and stopped via your application.

Note: You might want to run the CL Connector as a Windows service. If so, see Starting up TSA or CLC as Windows Service using the Service Wrapper.

In a terminal, change to your Terracotta server/ directory. Then run the start script with your cross-lang-config.xml and the ehcache.xml files:

%> cd /path/to/bigmemory-max-<version>/server
%> ./bin/ ../config-samples/cross-lang-config.xml ../config-samples/ehcache.xml

Note: For Microsoft Windows installations, use the BAT scripts, and where forward slashes ("/") are given in directory paths, substitute back slashes ("\").

Optionally, you can include the -pid <pidFileLocation> argument to provide a file for storing the process identifier (pid) of the started server process (for example, -pid /var/tmp/pid). This pidFileLocation can later be used to stop the server.


By default, logging goes to console and to a file called bigmem-connector-%u.log, located in the directory that contains the start script. You can override this by including -Dxplatform.log=/path/to/my.log with the start script. You can also re-enable console logging by including -Dxplatform.log.console with the start script.

Stopping the server (for future reference)

Use the script in server/bin/ directory of your kit. You can pass as an argument either <pid> (the pid of the server to stop) or -pid <pidFileLocation> (the file containing the pid of the server to stop).

Access your data

This section provides basic code snippets for accessing BigMemory data from your application. For more explanation, refer to the Cross-Language API section below. For the complete class library documentation, refer to the API documentation in the /apis/cpp/ directory of the kit.

Create a CacheManager

This snippet creates a CacheManager configuration that uses the Nirvana Shared Memory (SHM) transport and provisions a pool of 10 connections.

XPlatform::createCacheManager(terracotta::ehcache::config::Configuration("/dev/shm", 10));
Retrieve a Cache from the CacheManager

This snippet can be used with the demo code samples in the kit. Notice that a serializer must be specified.

cacheManager->getCache(cacheName, RecipeProtoBufSerializer());
Get or put entries into the cache

This snippet can be used with the demo code samples in the kit. Notice that you have the option to call the configured consistency type for get and put operations.

cache->put(key, recipeStructure, type);

Searches of BigMemory data can be made using the BigMemory Structured Query Language (SQL). Refer to the Search section on the API page.