MATLAB Engine API for Python memory overflow

24 ビュー (過去 30 日間)
含之
含之 2024 年 10 月 15 日
編集済み: 含之 2024 年 10 月 24 日
Python calls matlab.double, which is a very simple line of code, but it can be seen from the task manager that the memory has been soaring.I'm using a for loop to call this code constantly, and I'm also using some clear and other functions to clear the memory, but none of them have any effect unless the instance is restarted
import matlab.engine
test_matlab_engine = matlab.engine.start_matlab('-nodisplay -singleCompThread -nojvm')
def a():
data_array = []
for i in range(10000):
data_array.append(i)
a= matlab.double(data_array)
if __name__ == '__main__':
while True:
a()
  2 件のコメント
Aimee Nogoy
Aimee Nogoy 2024 年 10 月 16 日
Facing the same issue and still trying to debug. Using Python 3.10 and Matlab 2023b
含之
含之 2024 年 10 月 17 日
I'm in the same environment, and my final solution was to generate the .mat file, and matlab goes and reads the .mat file without variables to interact with.
My guess is that there is a memory leak in matlb.engine, but I don't really have a solution at the moment.

サインインしてコメントする。

回答 (1 件)

Jayanti
Jayanti 2024 年 10 月 22 日
I found a bug report similar to the issue you are facing. You can look for the workaround in the below link:
  1 件のコメント
含之
含之 2024 年 10 月 24 日
編集済み: 含之 2024 年 10 月 24 日
Thank you very much, I also saw this question, I also tried to download this attachment overlay, but the version is too different, I didn't succeed in trying, my matlab version is 2023b, python version is 3.11.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall MATLAB from Python についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by