Skip to content

Commit

Permalink
memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
steveww committed Mar 15, 2021
1 parent f072131 commit 2cf1695
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.instana.robotshop.shipping;

import java.util.List;
import java.util.Map;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -23,7 +23,7 @@ public class Controller {

private String CART_URL = String.format("http://%s/shipping/", getenv("CART_ENDPOINT", "cart"));

public static ArrayList bytesGlobal = new ArrayList<byte[]>();
public static List bytesGlobal = Collections.synchronizedList(new ArrayList<byte[]>());

@Autowired
private CityRepository cityrepo;
Expand All @@ -43,6 +43,14 @@ public int memory() {
byte[] bytes = new byte[1024 * 1024 * 25];
Arrays.fill(bytes,(byte)8);
bytesGlobal.add(bytes);

return bytesGlobal.size();
}

@GetMapping(path = "/free")
public int free() {
bytesGlobal.clear();

return bytesGlobal.size();
}

Expand Down

0 comments on commit 2cf1695

Please sign in to comment.