Skip to content

Commit

Permalink
Release version 1.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed Feb 9, 2022
1 parent 49c4e2e commit e941401
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

### February 11, 2022 version 1.5.7
* Add `Loader.clearCacheDir()` along with new `ClearMojo` and `-clear` command line option
* Speed up `Loader` on Windows when there are no symbolic links or library versions ([pull #512](https://github.com/bytedeco/javacpp/pull/512))
* Enhance `Pointer.physicalBytes()` by excluding shared pages from memory-mapped files, etc ([issue #468](https://github.com/bytedeco/javacpp/issues/468))
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ We can also have everything downloaded and installed automatically with:
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.5.6</version>
<version>1.5.7</version>
</dependency>
```

* Gradle (inside the `build.gradle` file)
```groovy
dependencies {
implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.6'
implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.7'
}
```

* Leiningen (inside the `project.clj` file)
```clojure
:dependencies [
[org.bytedeco/javacpp "1.5.6"]
[org.bytedeco/javacpp "1.5.7"]
]
```

* sbt (inside the `build.sbt` file)
```scala
libraryDependencies += "org.bytedeco" % "javacpp" % "1.5.6"
libraryDependencies += "org.bytedeco" % "javacpp" % "1.5.7"
```

Another option available to Gradle users is [Gradle JavaCPP](https://github.com/bytedeco/gradle-javacpp), and similarly for Scala users there is [SBT-JavaCPP](https://github.com/bytedeco/sbt-javacpp).
Expand Down
2 changes: 1 addition & 1 deletion platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-platform</artifactId>
<version>1.5.7-SNAPSHOT</version>
<version>1.5.7</version>

<name>JavaCPP Platform</name>
<description>The missing bridge between Java and native C++</description>
Expand Down
1 change: 1 addition & 0 deletions platform/src/main/assembly/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<exclude>*-javadoc.jar</exclude>
<exclude>*-sources.jar</exclude>
</excludes>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/site</directory>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.5.7-SNAPSHOT</version>
<version>1.5.7</version>

<name>JavaCPP</name>
<description>The missing bridge between Java and native C++</description>
Expand Down
1 change: 1 addition & 0 deletions src/main/assembly/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<exclude>*-javadoc.jar</exclude>
<exclude>*-sources.jar</exclude>
</excludes>
<fileMode>0644</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/site</directory>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/bytedeco/javacpp/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public static File cacheResource(URL resourceURL) throws IOException {
/**
* Extracts a resource, if the size or last modified timestamp differs from what is in cache,
* and returns the cached {@link File}. If target is not null, creates instead a symbolic link
* where the resource would have been extracted.
* where the resource would have been extracted. Directories from JAR files are extracted recursively.
*
* @param resourceURL the URL of the resource to extract and cache
* @param target of the symbolic link to create (must be null to have the resource actually extracted)
Expand Down Expand Up @@ -760,6 +760,7 @@ public static File extractResource(URL resourceURL, File directoryOrFile,
* Extracts a resource into the specified directory and with the specified
* prefix and suffix for the filename. If both prefix and suffix are {@code null},
* the original filename is used, so directoryOrFile must not be {@code null}.
* Directories from JAR files are extracted recursively.
*
* @param resourceURL the URL of the resource to extract
* @param directoryOrFile the output directory or file ({@code null == System.getProperty("java.io.tmpdir")})
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/bytedeco/javacpp/Pointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ public static long maxPhysicalBytes() {
* Also known as "anonymous resident set size" (Linux, Mac OS X, etc) or "private working set size" (Windows). */
@Name("JavaCPP_physicalBytes") public static native long physicalBytes();

/** May return a value larger than {@link #physicalBytes()} but less than {@code maxSize} to save processing time. */
@Name("JavaCPP_physicalBytes") public static native long physicalBytesInaccurate(long maxSize);

/** Returns the amount of physical memory installed according to the operating system, or 0 if unknown.
* It should not be possible for {@link #physicalBytes()} to go over this value. */
@Name("JavaCPP_totalPhysicalBytes") public static native long totalPhysicalBytes();
Expand Down Expand Up @@ -687,8 +690,19 @@ protected <P extends Pointer> P deallocator(Deallocator deallocator) {
this.deallocator = r;
if (referenceQueue != null) synchronized (DeallocatorThread.class) {
int count = 0;
long lastPhysicalBytes = maxPhysicalBytes > 0 ? physicalBytes() : 0;
long lastPhysicalBytes = 0;
try {
if (maxPhysicalBytes > 0) {
try {
lastPhysicalBytes = physicalBytesInaccurate(maxPhysicalBytes);
} catch (UnsatisfiedLinkError e) {
// old binaries with physicalBytesInaccurate() missing -> call physicalBytes() for backward compatibility
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage());
}
lastPhysicalBytes = physicalBytes();
}
}
while (count++ < maxRetries && ((maxBytes > 0 && DeallocatorReference.totalBytes + r.bytes > maxBytes)
|| (maxPhysicalBytes > 0 && lastPhysicalBytes > maxPhysicalBytes))) {
if (logger.isDebugEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bytedeco/javacpp/tools/ClearMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @author Samuel Audet
*/
@Mojo(name = "clear", defaultPhase = LifecyclePhase.NONE)
@Mojo(name = "clear", defaultPhase = LifecyclePhase.NONE, requiresProject = false)
public class ClearMojo extends AbstractMojo {
@Override public void execute() throws MojoExecutionException {
try {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/bytedeco/javacpp/tools/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ boolean classes(boolean handleExceptions, boolean defineAdapters, boolean conver
out.println("#endif");
out.println("}");
out.println();
out.println("static inline jlong JavaCPP_physicalBytes() {");
out.println("static inline jlong JavaCPP_physicalBytes(jlong maxSize = 0) {");
out.println(" jlong size = 0;");
out.println("#ifdef __linux__");
out.println(" static int fd = open(\"/proc/self/statm\", O_RDONLY, 0);");
Expand All @@ -567,6 +567,11 @@ boolean classes(boolean handleExceptions, boolean defineAdapters, boolean conver
out.println(" size = (jlong)info.internal;");
out.println(" }");
out.println("#elif defined(_WIN32)");
out.println(" PROCESS_MEMORY_COUNTERS counters;");
out.println(" if (GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters))) {");
out.println(" jlong size2 = (jlong)counters.WorkingSetSize;");
out.println(" if (size2 <= maxSize) return size2;");
out.println(" }");
out.println(" DWORD length = sizeof(PSAPI_WORKING_SET_INFORMATION);");
out.println(" PSAPI_WORKING_SET_INFORMATION *info = (PSAPI_WORKING_SET_INFORMATION*)malloc(length);");
out.println(" BOOL success = QueryWorkingSet(GetCurrentProcess(), info, length);");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/bytedeco/javacpp/PointerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,6 @@ static class TestFunction extends FunctionPointer {
long bytesAfter = Pointer.physicalBytes();

System.out.println(bytesBefore + " " + bytesAfter);
assertTrue(Math.abs(bytesAfter - bytesBefore) < 10_000_000 + buffer.get(0));
assertTrue(Math.abs(bytesAfter - bytesBefore) < 100_000_000 + buffer.get(0));
}
}

0 comments on commit e941401

Please sign in to comment.