Merge lp:~yrke/tapaal/memoryMonitor-nullpointer into lp:tapaal

Proposed by Kenneth Yrke Jørgensen on 2020-08-24
Status: Merged
Approved by: Jiri Srba on 2020-08-24
Approved revision: 1089
Merged at revision: 1089
Proposed branch: lp:~yrke/tapaal/memoryMonitor-nullpointer
Merge into: lp:tapaal
Diff against target: 23 lines (+8/-5)
1 file modified
src/dk/aau/cs/util/MemoryMonitor.java (+8/-5)
To merge this branch: bzr merge lp:~yrke/tapaal/memoryMonitor-nullpointer
Reviewer Review Type Date Requested Status
Jiri Srba 2020-08-24 Approve on 2020-08-24
Review via email: mp+389720@code.launchpad.net
To post a comment you must log in.
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/util/MemoryMonitor.java'
2--- src/dk/aau/cs/util/MemoryMonitor.java 2020-08-10 07:11:17 +0000
3+++ src/dk/aau/cs/util/MemoryMonitor.java 2020-08-24 14:21:21 +0000
4@@ -80,11 +80,14 @@
5 }else{
6 try {
7 Process p = Runtime.getRuntime().exec("ps -p "+PID+" -o rss");
8- BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
9-
10- input.readLine(); //Actual memory usage is second line output
11- String s = input.readLine();
12- memory = Double.parseDouble(s.replace(" ", ""))/1024;
13+ BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
14+
15+ String s = input.readLine(); //Actual memory usage is second line output
16+ s = input.readLine();
17+
18+ if (s!=null) { //Not sure why s would be null, but it seems to happen some time on MacOS
19+ memory = Double.parseDouble(s.replace(" ", "")) / 1024;
20+ }
21 } catch (IOException e) {
22 Logger.log(e);
23 }

Subscribers

People subscribed via source and target branches