{"id":21597456,"url":"https://github.com/cerus/sharedmem","last_synced_at":"2025-04-11T00:52:55.966Z","repository":{"id":57731118,"uuid":"395077018","full_name":"cerus/sharedmem","owner":"cerus","description":"Shared memory for Java","archived":false,"fork":false,"pushed_at":"2023-04-15T22:07:47.000Z","size":109,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T00:52:44.715Z","etag":null,"topics":["cpp","hacktoberfest","java","java-native-interface","memory-mapped-file","shared-memory"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cerus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"cerus"}},"created_at":"2021-08-11T18:04:58.000Z","updated_at":"2023-11-10T09:34:50.000Z","dependencies_parsed_at":"2023-02-08T04:35:13.525Z","dependency_job_id":null,"html_url":"https://github.com/cerus/sharedmem","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fsharedmem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fsharedmem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fsharedmem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerus%2Fsharedmem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cerus","download_url":"https://codeload.github.com/cerus/sharedmem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322609,"owners_count":21084336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","hacktoberfest","java","java-native-interface","memory-mapped-file","shared-memory"],"created_at":"2024-11-24T18:09:03.102Z","updated_at":"2025-04-11T00:52:55.943Z","avatar_url":"https://github.com/cerus.png","language":"Java","readme":"\u003cdiv style=\"text-align: center;\"\u003e\n    \u003ccenter\u003e\u003cpre\u003e\n███████ ██   ██  █████  ██████  ███████ ██████  ███    ███ ███████ ███    ███\n██      ██   ██ ██   ██ ██   ██ ██      ██   ██ ████  ████ ██      ████  ████\n███████ ███████ ███████ ██████  █████   ██   ██ ██ ████ ██ █████   ██ ████ ██\n     ██ ██   ██ ██   ██ ██   ██ ██      ██   ██ ██  ██  ██ ██      ██  ██  ██\n███████ ██   ██ ██   ██ ██   ██ ███████ ██████  ██      ██ ███████ ██      ██\nShared memory for Java\n    \u003c/pre\u003e\u003c/center\u003e\n\n   \u003cp align=\"center\"\u003e\u003cimg src=\"https://img.shields.io/github/license/cerus/sharedmem\" alt=\"GitHub\"\u003e \u003ca href=\"https://github.com/cerus/sharedmem/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/cerus/sharedmem\" alt=\"GitHub issues\"\u003e\u003c/a\u003e \u003ca href=\"https://github.com/cerus/sharedmem/releases/latest\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/cerus/sharedmem\" alt=\"GitHub release (latest by date)\"\u003e\u003c/a\u003e \u003cimg src=\"https://img.shields.io/github/stars/cerus/sharedmem\" alt=\"GitHub Repo stars\"\u003e \u003ca href=\"https://github.com/sponsors/cerus\"\u003e\u003cimg src=\"https://img.shields.io/github/sponsors/cerus\" alt=\"GitHub Sponsors\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n## Table of contents\n\n- What is sharedmem?\n- Compatibility\n- Installation\n- Usage\n- Examples\n- Contributing\n- Building from source\n- Licenses\n\n## What is sharedmem?\n\nsharedmem allows you to access shared memory / memory mapped files in Java. sharedmem is basically an abstraction layer on top of\nthe [boost interprocess](https://www.boost.org/doc/libs/1_76_0/doc/html/interprocess.html) library.\n\n\u003e **WARNING**\\\n\u003e I have basically zero experience with C++ so the native code is probably awful. Someone with more experience than me has to clean that up\n\u003e eventually.\n\n## Compatibility\n\nsharedmem is compatible with Linux and Windows.\n\n## Installation\n\nSimply integrate sharedmem with your favorite build tool into your project, and you are good to go.\n\nMaven:\n\n```xml\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003edev.cerus\u003c/groupId\u003e\n        \u003cartifactId\u003esharedmem\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Usage\n\n[Javadocs](https://cerus.dev/api/sharedmem)\n\nCreate a new memory mapped file object:\\\n`MemoryMappedFile mmf = MemoryMappedFile.of(\"name\");`\n\nDon't forget to open before you start reading / writing:\\\n`mmf.open(MemoryMappedFile.OpenMode.CREATE_OR_OPEN, MemoryMappedFile.RWMode.READ_WRITE, 16);`\n\nRead:\\\n`byte[] data = mmf.read(0, -1);`\n\nWrite:\\\n`mmf.write(0, new byte[] { 1, 2, 3 }`\n\nIn order to load the native library, sharedmem needs to save it to a temporary folder on the disk. If you don't want that you can enable \"primitive\nloading\" by calling `LibraryLoader.enablePrimitiveLoading()`. Ensure that the native library is in Java's library folder if you enable this.\n\n## Examples\n\n```java\nclass Example {\n\n    public static void main(String[] args) {\n        // Opens or creates \"Local\\\\test_map\" and writes a sequence of [1, 2, 3] at random places\n\n        // Create and open file\n        final MemoryMappedFile file = MemoryMappedFile.of(\"Local\\\\test_map\");\n        long capacity = 32; // capacity = size in bytes - Only used when creating a memory mapped file\n        file.open(MemoryMappedFile.OpenMode.CREATE_OR_OPEN, MemoryMappedFile.RWMode.READ_WRITE, capacity);\n\n        // Write sequence and read whole file\n        file.write(ThreadLocalRandom.current().nextInt(0, 29), new byte[] {1, 2, 3});\n        int length = -1; // -1 if you want to read the whole file\n        final byte[] read = file.read(0, length);\n\n        // Close file (will *not* delete/remove the memory mapped file)\n        file.close();\n\n        // Print contents\n        System.out.println(Arrays.toString(read));\n\n        // Example output after running this for a few times:\n        // [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 3, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 1, 2, 3]\n    }\n}\n```\n\n## Building from source\n\n**Linux**\\\nRequirements: Java 11, Maven, Git, g++\\\nAdjust your JAVA_HOME in `build.sh` and run `./build.sh`\n\n**Windows**\\\nRequirements: Java 11, Maven, MinGW GCC, Boost libraries\n\n1. Download the Boost libraries (https://www.boost.org/users/download/)\n2. Unzip the libraries in the project directory\n3. Run `build_native.bat`\n4. Copy `target\\libsharedmem.dll` into `src\\main\\resources`\n5. Run `mvn clean package`\n\n## Licenses\n\nThis project is licenses under the [MIT License](LICENSE.txt).\n\nThirdparty licenses: [Boost](BOOST_LICENSE.txt)","funding_links":["https://github.com/sponsors/cerus"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerus%2Fsharedmem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcerus%2Fsharedmem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerus%2Fsharedmem/lists"}