Skip to content

Commit

Permalink
Merge pull request #155 in TELIMA/karnak from feat/test_memory_releas…
Browse files Browse the repository at this point in the history
…e to develop

* commit '7e36762cf190313ba6f0249bcdc51fe0c6e3a3e5':
  feat: test call garbage
  • Loading branch information
jdcshug committed Aug 10, 2022
2 parents 34bb5e4 + 7e36762 commit 0487b34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</licenses>

<!-- Version -->
<version>1.0.45</version>
<version>1.0.46</version>

<!-- Packaging -->
<packaging>jar</packaging>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/karnak/backend/service/MemoryService.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
package org.karnak.backend.service;

import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service

public class MemoryService {

@Scheduled(fixedRate = 30 * 1000)
private static final Logger LOGGER = LoggerFactory.getLogger(MemoryService.class);


@Scheduled(fixedRate = 10 * 1000)
public void callGarbageCollector() {
LOGGER.info("Memory:%d \t \t %d \t \t %d".formatted(Runtime.getRuntime().freeMemory(),
Runtime.getRuntime().totalMemory(), Runtime.getRuntime().maxMemory()));

System.gc();
System.runFinalization();
System.gc();
System.runFinalization();

LOGGER.info("Memory:%d \t \t %d \t \t %d".formatted(Runtime.getRuntime().freeMemory(),
Runtime.getRuntime().totalMemory(), Runtime.getRuntime().maxMemory()));
try {
TimeUnit.MILLISECONDS.sleep(200);
} catch (InterruptedException et) {
Expand Down

0 comments on commit 0487b34

Please sign in to comment.