Skip to content

Commit bf526a5

Browse files
committed
Fixes #111
1 parent 1a0aa2f commit bf526a5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
"type": "boolean",
126126
"default": false,
127127
"description": "Show output channel when typechecking finished."
128+
},
129+
"idris.numbersOfContinuousTypechecking": {
130+
"type": "number",
131+
"default": 10,
132+
"description": "Kill Idris process every N times of typechecking to avoid memory leaking."
128133
}
129134
}
130135
},

src/idris/commands.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ let typeCheckingStatusItem = vscode.window.createStatusBarItem(vscode.StatusBarA
2424
let totalityCheckingStatusItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, -2)
2525
let buildCheckingStatusItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, -3)
2626

27+
let killIdrisCounter = 0;
28+
2729
let init = (compilerOptions) => {
2830
if (compilerOptions) {
2931
innerCompilerOptions = compilerOptions
@@ -210,6 +212,8 @@ let buildIPKG = (uri) => {
210212

211213
let typecheckFile = (uri) => {
212214
let needShowOC = vscode.workspace.getConfiguration('idris').get('showOutputWhenTypechecking')
215+
let limit = vscode.workspace.getConfiguration('idris').get('numbersOfContinuousTypechecking')
216+
213217
let successHandler = (_) => {
214218
if (needShowOC) {
215219
outputChannel.clear()
@@ -219,14 +223,24 @@ let typecheckFile = (uri) => {
219223
tcDiagnosticCollection.clear()
220224
typeCheckingStatusItem.text = "Idris: Type checking ✔︎"
221225
typeCheckingStatusItem.show()
222-
destroy(true)
226+
if (killIdrisCounter < limit) {
227+
killIdrisCounter++
228+
} else {
229+
killIdrisCounter = 0
230+
destroy(true)
231+
}
223232
}
224233

225234
new Promise((resolve, _reject) => {
226235
model.load(uri).filter((arg) => {
227236
return arg.responseType === 'return'
228237
}).subscribe(successHandler, (err) => {
229-
destroy(true)
238+
if (killIdrisCounter < limit) {
239+
killIdrisCounter++
240+
} else {
241+
killIdrisCounter = 0
242+
destroy(true)
243+
}
230244
if (needShowOC) {
231245
displayErrors(err)
232246
}

0 commit comments

Comments
 (0)