DavePearce / EvmTools

Various utilities for working with the Etherem Reference Tests.
Apache License 2.0
2 stars 0 forks source link

JSONObject.toString() on large files #8

Open DavePearce opened 2 years ago

DavePearce commented 2 years ago

It seems that JSONObject.toString() is causing an out-of-memory error on large files (e.g. stMemoryTest/buffer.json). Specifically at this point:

public void run() throws IOException, JSONException {
    // Read contents of fixture file
    String contents = Files.readString(inFile);
    JSONObject json = convertState2TraceTest(new JSONObject(contents));
    if(prettify) {
        out.print(json.toString(2));
    } else {
        out.print(json.toString()); // crashes here.
    }
}

I wonder what we can do about this. For example, some kind of convert on demand approach using an OutputStream ?

DavePearce commented 2 years ago

Potentially the JSONWriter class might be the ticket here. Yes, convertState2TraceTest can be modified to use this, and that would probably help significantly.