How to load efficiently load a file into a variable (memory)?

Discussion in 'Cadence' started by jmss, Sep 26, 2007.

  1. jmss

    jmss Guest

    Hi.

    How can I rean an entire large file into memory in an efficient way?
    The file contents are lists (of lists (of lists...))

    I tried 'load' but it gives a value stack overflow. The file around 8
    MB.

    Thanks and best regards,
    João M. S. Silva
     
    jmss, Sep 26, 2007
    #1
  2. I just read a file which contained a list (of lists of lists of lists) which was
    somewhat bigger than 8Mbyte ) by using lineread() to read the data in the file.

    That said, by having an assignment in the file, I could also load it
    using load() - so not sure what your problem is.

    Perhaps you should report it to Cadence customer support?

    Regards,

    Andrew.
     
    Andrew Beckett, Oct 1, 2007
    #2
  3. jmss

    Nicolas Guest

    You may also try parsing the file. In other words, strip out the
    skill "list()" calls around your data and replace with something like
    tabs. Don't load the file, instead, open() it, and read it line by
    line. I believe SKILL limits the size of a skill file it can load by
    the number of lines or size, can't recall the exact limitation. If
    you parse and build your lists manually, you can circumvent that
    mechanism and only be left to deal with the memory size available for
    your lists.

    Nicolas
     
    Nicolas, Oct 1, 2007
    #3
  4. jmss

    jmss Guest

    Hi,

    I'm managing to solve the problem by changing the format of the file
    to be loaded to one list per line, so that I can do:

    (while (gets line port)
    buffer = (tconc buffer (readstring line))
    )
    buffer = car(buffer)

    The problem is that I have lines larger than the limit of gets(). How
    can I change the gets() macro to accept larger string sizes?

    Thanks.
     
    jmss, Oct 3, 2007
    #4
  5. A value stack overflow generally means that you passed too many
    arguments to a function. I'm guessing this means that your file
    looked like:

    SomeGlobalVar = list(1 2 3 4 ... 800000)

    Rather than construct a new list from static data, you could just dump
    the literal list to a file and read but not evaluate that expression.
    So you'd have a file called something like "foo.sexp" which contains a
    single structured expression, which you would "load" in without using
    the function load:

    in = infile("foo.sexp")
    SomeGlobalVar = (car (lineread in))
    close(in)

    Now SomeGlobalVar should contain your very large list without hitting
    any object or stack size limitations.
     
    Thomas F. Burdick, Oct 3, 2007
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.