Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeBufferAllocator: release memory when buffer object is GCed #67

Merged
merged 60 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
751e1ae
NativeBufferAllocator: automatically release buffer memory when buffe…
Ali-RS Mar 27, 2023
1d36920
Changed log level.
Ali-RS Mar 27, 2023
48a31a1
NativeBufferUtils: reverted code
pavly-gerges Mar 27, 2023
fcbdc14
GarbageCollectibleBuffers: basic API
pavly-gerges Mar 27, 2023
7ce8ea0
GarbageCollectibleBuffers: added jme interface
pavly-gerges Mar 27, 2023
03eb6df
NativeBufferUtils: added `NativeBufferUtils#destroy(long)`
pavly-gerges Mar 27, 2023
1a6201e
jmealloc-natives: added native implementation for `NativeBufferUtils#…
pavly-gerges Mar 27, 2023
efe2d00
jme-alloc-natives: fixed too few args error for `destroy0(void*)`
pavly-gerges Mar 27, 2023
3ce4d20
com_jme3_alloc_util_NativeBufferUtils.c: fix `getMemoryAddress(JNIEnv…
pavly-gerges Mar 27, 2023
6e3c309
GarbageCollectibleBuffers: keep track of created buffer addresses to …
pavly-gerges Mar 28, 2023
d2fe2c2
API: refactored `NativeBufferUtils#getMemoryAddress(Buffer)` to use a…
pavly-gerges Mar 28, 2023
8265ed9
API: Code-Optimizations
pavly-gerges Mar 28, 2023
4540458
GarbageCollectibles-API: added loggers
pavly-gerges Mar 28, 2023
0ecb303
GarbageCollectibles: further optimizations by hiding the Collectibles…
pavly-gerges Mar 28, 2023
f4ee922
GarbageCollectibles: made MemoryScavenger package-private
pavly-gerges Mar 28, 2023
1276740
GarbageCollectibles-API: refactored to OOP
pavly-gerges Mar 28, 2023
55b317e
MemoryScavenger#LOGGER: removed static modifier
pavly-gerges Mar 28, 2023
370983a
Merge branch 'fix-memory-leak' of https://github.com/Ali-RS/jme-alloc…
pavly-gerges Mar 28, 2023
128448a
NativeBufferAllocator: opened fields for inheritance
pavly-gerges Mar 28, 2023
b03ad7c
GarbageCollectibles-API: disabled SEVERE logs for GC queue
pavly-gerges Mar 28, 2023
c6cb704
GarbageCollectibleBuffers: refactored the list to HashMap for a bette…
pavly-gerges Mar 28, 2023
68a405e
GarbageCollectibleBuffers: fixed the LOGGER
pavly-gerges Mar 28, 2023
c5679d6
GarbageCollectibleBuffers: added the created buffers as the values of…
pavly-gerges Mar 28, 2023
55a1ee8
API: added a thread-safe implementation
pavly-gerges Mar 29, 2023
c33ecbb
GarbageCollectibles-API: simplified the class-generic at ReferenceQueue
pavly-gerges Mar 29, 2023
27f88f8
GarbageCollectibles-API: added jme3-copyright
pavly-gerges Mar 29, 2023
1f5b34f
GarbageCollectibles-API: added missing javadocs
pavly-gerges Mar 29, 2023
05b0d3a
GarbageCollectibles-API: use abstract Buffer instead of ByteBuffer
pavly-gerges Mar 29, 2023
5e8b7c4
Allocators: added missing docs
pavly-gerges Mar 29, 2023
5866eed
GarbageCollectibleBuffers: added missing docs `@params` tags
pavly-gerges Mar 29, 2023
d9260f5
jme3-alloc-examples: added blank-templates
pavly-gerges Mar 29, 2023
807d36a
GarbageCollectibles-API: added package docs
pavly-gerges Mar 29, 2023
8596e18
jmealloc.h: added extra logging
pavly-gerges Mar 30, 2023
acfed01
jni-getMemoryAddress: explicit cast to jlong
pavly-gerges Mar 30, 2023
b014c30
NativeBufferUtils#getMemoryAddress(Buffer) typo
pavly-gerges Mar 30, 2023
26663a9
TestConcurrentBufferAllocator: basic example
pavly-gerges Mar 30, 2023
8426830
workflows: added debug-test
pavly-gerges Mar 30, 2023
ae7a4f4
workflows/debug-test.yml: restricted testing to ubuntu-linux
pavly-gerges Mar 30, 2023
03a44a4
TestConcurrentBufferAllocator: removed main-thread block
pavly-gerges Mar 30, 2023
73ef6f8
workflows/debug-test.yml:test-job: removed bash shebang
pavly-gerges Mar 30, 2023
86a63db
workflows/debug-test.yml:test-job: reverted bash shebang and correcte…
pavly-gerges Mar 30, 2023
3c77582
TestConcurrentBufferAllocator: added missing parts
pavly-gerges Mar 30, 2023
4390fc8
workflows/debug-test.yml:test-job: added TestConcurrentAllocator
pavly-gerges Mar 30, 2023
1b56bba
TestConcurrentBufferAllocator: added missing imports
pavly-gerges Mar 30, 2023
0327cb3
workflows/debug-test.yml: fix indentation errors
pavly-gerges Mar 30, 2023
b61f988
Helper-scripts: moved abstract scripts to abstract folder
pavly-gerges Mar 30, 2023
3064bbe
maven-publish: added a debug publish script
pavly-gerges Mar 30, 2023
97143b9
workflows/debug-deploy.yml: deploying a debug version
pavly-gerges Mar 30, 2023
7779c53
Refactored class-members names to follow google-style
pavly-gerges Mar 31, 2023
c2c4681
GarbageCollectibles-API: refactor loggers to class-variables
pavly-gerges Mar 31, 2023
8499d3c
NativeBinaryLoader: follow google style of code on some class variables
pavly-gerges Mar 31, 2023
9f64d7d
NativeBufferAllocator: follow google-style on instance-variables
pavly-gerges Mar 31, 2023
c578e5c
GarbageCollectibleBuffers: simplified duplicate-destruction logging
pavly-gerges Mar 31, 2023
240507b
NativeBufferAllocator: added missing docs for instance-variable `coll…
pavly-gerges Mar 31, 2023
5efac3e
NativeDynamicLibrary: added missing docs for `LIBRARY_BASE_NAME`
pavly-gerges Mar 31, 2023
c97602b
GarbageCollectibleBuffers: fixed `register` method sig on docs
pavly-gerges Mar 31, 2023
277b328
GarbageCollectibleBuffer: added final modifier for memoryAddress
pavly-gerges Mar 31, 2023
cf6a516
GarbageCollectibles-API: refactored to GarbageCollectibleAllocator - …
pavly-gerges Apr 4, 2023
9152133
GarbageCollectibles-API: fixed documentation errors
pavly-gerges Apr 4, 2023
773cf01
jme3-alloc-examples: added TestReleaseDirectMemory.java for stress te…
pavly-gerges Apr 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Build jme-alloc
name: Build and Test jme-alloc

# Controls when the workflow will run
on:
Expand Down
316 changes: 316 additions & 0 deletions .github/workflows/debug-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
# This workflow builds the API and releases a debug version to Maven-Sonatype-Central repository

name: Deploy jme-alloc debug

# Runs this workflow [on-release] only
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
release:
types: [published]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
compile-java:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Compile java

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Oracle-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '19'

- name: Compiling java
run: ./gradlew --console="verbose" :jme3-alloc:compileJava

- name: Archive byte code
uses: actions/upload-artifact@v3
with:
name: byte-code
path: jme3-alloc/build/classes/java/main/

- name: Archive jni headers
uses: actions/upload-artifact@v3
with:
name: jni-headers
path: jme3-alloc-native/src/include/

compile-natives:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
needs: compile-java
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
name: Compile natives on ${{ matrix.os }} for x86-64 and x86

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Oracle-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '19'

- name: Download jni headers
uses: actions/download-artifact@v3
with:
name: jni-headers
path: jme3-alloc-native/src/include/

- name: Prepare build directory
run: ./gradlew --console="verbose" :jme3-alloc-native:prepareDesktopOutputDirectory

- name: Compiling x86-64 on ${{ matrix.os }}
run: ./gradlew --console="verbose" :jme3-alloc-native:compileX86_64_debug

- name: Install gcc-multilib
run: bash ./helper-scripts/abstract/install-gcc-multilib.sh

- name: Compiling x86 on ${{ matrix.os }}
run: ./gradlew --console="verbose" :jme3-alloc-native:compileX86_debug

- name: Archive libjmealloc.so
uses: actions/upload-artifact@v3
with:
name: libjmealloc-${{ matrix.os }}
path: jme3-alloc-native/build/

assemble-desktop:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
needs: compile-natives
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Assemble jme3-alloc-desktop

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Oracle-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '19'

- name: Downloading libjmealloc-ubuntu-latest
uses: actions/download-artifact@v3
with:
name: libjmealloc-ubuntu-latest
path: jme3-alloc-native/build/

- name: Downloading libjmealloc-macos-latest
uses: actions/download-artifact@v3
with:
name: libjmealloc-macos-latest
path: jme3-alloc-native/build/

- name: Downloading libjmealloc-windows-latest
uses: actions/download-artifact@v3
with:
name: libjmealloc-windows-latest
path: jme3-alloc-native/build/

- name: Downloading byte code
uses: actions/download-artifact@v3
with:
name: byte-code
path: jme3-alloc/build/classes/java/main/

- name: Copying natives
run: ./gradlew --console="verbose" :jme3-alloc-native:copyNatives

- name: List build
run: tree jme3-alloc/build/classes/java/main/

- name: Assemble
run: ./gradlew --console="verbose" -Pversion=${GITHUB_REF_NAME} :jme3-alloc:desktop && ./gradlew --console="verbose" -Pversion=${GITHUB_REF_NAME} :jme3-alloc:assemble

- name: Log jar
run: tree jme3-alloc/build/libs/

- name: Archive release
uses: actions/upload-artifact@v3
with:
name: jme3-alloc-desktop-release
path: jme3-alloc/build/libs/*.jar

compile-android-natives:
# a linux runner image with the ndk installed and llvm ready to compile android native binaries
runs-on: ${{ matrix.os }}
needs: compile-java
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Compiling android native binaries

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Oracle-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '19'

- name: Download jni headers
uses: actions/download-artifact@v3
with:
name: jni-headers
path: jme3-alloc-native/src/include/

- name: Prepare build directory
run: ./gradlew --console="verbose" :jme3-alloc-native:prepareAndroidOutputDirectory

- name: Compiling android native binaries
run: ./gradlew --console="verbose" :jme3-alloc-native:compileAndroidDebug

- name: Archive libjmealloc.so
uses: actions/upload-artifact@v3
with:
name: libjmealloc-android
path: jme3-alloc-native/build/

assemble-android:
# runner images with architectures (variants)
runs-on: ${{ matrix.os }}
needs: compile-android-natives
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Assembling jme3-alloc-android native binaries

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Oracle-JDK-19
uses: actions/setup-java@v3
with:
distribution: 'oracle'
java-version: '19'

- name: Downloading libjmealloc-android
uses: actions/download-artifact@v3
with:
name: libjmealloc-android
path: jme3-alloc-native/build/

- name: Downloading byte code
uses: actions/download-artifact@v3
with:
name: byte-code
path: jme3-alloc/build/classes/java/main/

- name: Copying natives
run: ./gradlew --console="verbose" :jme3-alloc-native:copyNatives

- name: List build
run: tree jme3-alloc/build/classes/java/main/

- name: Assemble
run: ./gradlew --console="verbose" -Pversion=${GITHUB_REF_NAME} :jme3-alloc:android && ./gradlew --console="verbose" -Pversion=${GITHUB_REF_NAME} :jme3-alloc:assemble

- name: Log jar
run: tree jme3-alloc/build/libs/

- name: Archive release
uses: actions/upload-artifact@v3
with:
name: jme3-alloc-android-release
path: jme3-alloc/build/libs/*.jar

deploy:
environment:
name: maven-central
url: https://repo.maven.apache.org/maven2/io/github/software-hardware-codesign/
runs-on: ${{ matrix.os }}
needs: [assemble-desktop, assemble-android]
strategy:
matrix:
os: [ 'ubuntu-latest' ]
name: Deploying to Maven-Central repository

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout Job
uses: actions/checkout@v3

- name: Setup Temurin-OpenJDK-17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Setup maven-3.9
run: |
# remove shipped maven-3.8 that causes the plexus plugin incompatibility behavior
sudo apt remove maven
# installs maven-3.9 with the fixed plugins patch
chmod +rwx ./helper-scripts/project-impl/publishing/install-maven-latest.sh
./helper-scripts/project-impl/publishing/install-maven-latest.sh

- name: Use Predefined PGP Keybox
run: gpg --import ./helper-scripts/project-impl/publishing/public-key.pub

- name: Import secret-key
run: gpg --allow-secret-key-import --import --batch --yes --passphrase="jme-alloc" ./helper-scripts/project-impl/publishing/secret-key

- name: Import owner-trust
run: gpg --import-ownertrust ./helper-scripts/project-impl/publishing/owner-trust.txt

- name: Send public key 'jme-alloc'
# sends the public key to a maven compatible host
run: gpg --keyserver keyserver.ubuntu.com --send-keys 8DB84BBFCFCCCA00EF7A53A8022AE2B9E8991B20

- name: Generate sources jar
run: ./gradlew -Pversion=$GITHUB_REF_NAME :jme3-alloc:generateSourcesJar

- name: Generate javadoc jar
run: ./gradlew -Pversion=$GITHUB_REF_NAME :jme3-alloc:generateJavadocJar

- name: Download desktop jar
uses: actions/download-artifact@v3
with:
name: jme3-alloc-desktop-release
path: jme3-alloc/build/libs/

- name: Download android jar
uses: actions/download-artifact@v3
with:
name: jme3-alloc-android-release
path: jme3-alloc/build/libs/

- name: Deploying jme3-alloc binaries
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
run: |
chmod +rwx ./helper-scripts/project-impl/publishing/sonatype-publish-debug-artifacts.sh
# publish artifacts using the tag version
./helper-scripts/project-impl/publishing/sonatype-publish-debug-artifacts.sh $GITHUB_REF_NAME
Loading