JAVA heap space memory issue

15 ビュー (過去 30 日間)
Karan
Karan 2023 年 6 月 20 日
編集済み: Kevin Gurney 2023 年 6 月 20 日
I have an XML file of approximate 1 GB size.
I have used xmlread command in my script which always leads to below error:
Java exception occurred:
java.lang.OutOfMemoryError: Java heap space
I maximized the Java Heap Memory under Preferences to 4016 MB.But I am still getting the same issue.
Any work around?

回答 (1 件)

Kevin Gurney
Kevin Gurney 2023 年 6 月 20 日
編集済み: Kevin Gurney 2023 年 6 月 20 日
You could try using the newer MATLAB APIs for XML Processing (MAXP) or readstruct rather than xmlread. Neither of these interfaces use Java under the hood.
However, there is still a possibility of out of memory issues if your XML file is too large relative to the amount of available memory on your machine.
MAXP Example:
import matlab.io.xml.dom.*
filename = "data.xml"
dom = parseFile(Parser, filename);
readstruct Example:
filename = "data.xml"
s = readstruct(filename);
Ultimately, if your XML file is too large to load into memory all at once, then you may need to use a streaming / "chunk"-based parsing approach. For example, you could try to leverage a SAX based Java parser or other third party SAX parser to only read parts of the file at a time to decrease maximum memory usage.

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by