Skip to content

Commit c4c1575

Browse files
committed
[GR-26640] [GR-26642] Fix more memory leaks and remove slow getInstanceShape method
PullRequest: graalpython/1378
2 parents 9c99c29 + d6f1bba commit c4c1575

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ static Object doSingleton(@SuppressWarnings("unused") CExtContext cextContext, @
434434
return nativeWrapper;
435435
}
436436

437-
@Specialization(guards = "object == cachedObject", limit = "3")
437+
@Specialization(guards = "object == cachedObject", limit = "3", assumptions = "singleContextAssumption()")
438438
static Object doPythonClass(@SuppressWarnings("unused") CExtContext cextContext, @SuppressWarnings("unused") PythonManagedClass object,
439-
@SuppressWarnings("unused") @Cached("object") PythonManagedClass cachedObject,
440-
@Cached("wrapNativeClass(object)") PythonClassNativeWrapper wrapper) {
439+
@SuppressWarnings("unused") @Cached(value = "object", weak = true) PythonManagedClass cachedObject,
440+
@Cached(value = "wrapNativeClass(object)", weak = true) PythonClassNativeWrapper wrapper) {
441441
return wrapper;
442442
}
443443

@@ -690,10 +690,10 @@ static Object doSingleton(@SuppressWarnings("unused") CExtContext cextContext, @
690690
return nativeWrapper;
691691
}
692692

693-
@Specialization(guards = "object == cachedObject", limit = "3")
693+
@Specialization(guards = "object == cachedObject", limit = "3", assumptions = "singleContextAssumption()")
694694
static Object doPythonClass(@SuppressWarnings("unused") CExtContext cextContext, @SuppressWarnings("unused") PythonManagedClass object,
695-
@SuppressWarnings("unused") @Cached("object") PythonManagedClass cachedObject,
696-
@Cached("wrapNativeClass(object)") PythonClassNativeWrapper wrapper) {
695+
@SuppressWarnings("unused") @Cached(value = "object", weak = true) PythonManagedClass cachedObject,
696+
@Cached(value = "wrapNativeClass(object)", weak = true) PythonClassNativeWrapper wrapper) {
697697
wrapper.increaseRefCount();
698698
return wrapper;
699699
}
@@ -873,10 +873,10 @@ static Object doSingleton(CExtContext cextContext, PythonAbstractObject object,
873873
return ToNewRefNode.doSingleton(cextContext, object, contextRef);
874874
}
875875

876-
@Specialization(guards = "object == cachedObject", limit = "3")
876+
@Specialization(guards = "object == cachedObject", limit = "3", assumptions = "singleContextAssumption()")
877877
static Object doPythonClass(@SuppressWarnings("unused") CExtContext cextContext, @SuppressWarnings("unused") PythonManagedClass object,
878-
@SuppressWarnings("unused") @Cached("object") PythonManagedClass cachedObject,
879-
@Cached("wrapNativeClass(object)") PythonClassNativeWrapper wrapper) {
878+
@SuppressWarnings("unused") @Cached(value = "object", weak = true) PythonManagedClass cachedObject,
879+
@Cached(value = "wrapNativeClass(object)", weak = true) PythonClassNativeWrapper wrapper) {
880880
wrapper.increaseRefCount();
881881
return wrapper;
882882
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected static AllocationReporter getAllocationReporter(ContextReference<Pytho
207207
return contextRef.get().getEnv().lookup(AllocationReporter.class);
208208
}
209209

210-
private PythonLanguage getLanguage() {
210+
public PythonLanguage getLanguage() {
211211
return executeGetLanguage(true, 0.0);
212212
}
213213

mx.graalpython/mx_graalpython.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ def punittest(ars):
213213
# test leaks with shared engine Python code only
214214
run_leak_launcher(common_args + ["--shared-engine", "--code", "pass"]),
215215
# test leaks with shared engine when some C module code is involved
216-
# Not working due to GR-26175
217216
# run_leak_launcher(common_args + ["--shared-engine", "--code", "import _testcapi, mmap, bz2; print(memoryview(b'').nbytes)"])
218217
]):
219218
mx.abort(1)
@@ -2025,7 +2024,7 @@ def run_leak_launcher(input_args, out=None):
20252024
# rerun once with heap dumping enabled
20262025
out = mx.OutputCapture()
20272026
run_leak_launcher(["--keep-dump"] + input_args, out=out)
2028-
path = out.data.strip().split("Dump file:")[2].strip()
2027+
path = out.data.strip().partition("Dump file:")[2].strip()
20292028
if path:
20302029
save_path = os.path.join(SUITE.dir, "dumps", "leak_test")
20312030
try:

0 commit comments

Comments
 (0)