Question about massive arrays and memory

Discussion in 'C Programming' started by Cyhawk, Nov 1, 2005.

  1. Cyhawk

    Cyhawk Guest

    Hello. Im working on a game, (mud actually) (socketmud for anyone who
    cares ;) and ive decided on a very large array to hold my world data.
    (Nethack style, every cord == number == represents a charater/sector).
    Im using gzread/gzsave to store/load the array from file, which is
    nice, im using about 230k disk space when the world is filled. However,
    in memory its roughly 35megs ([1000][750][11]). Ive googled around, and
    asked people, and theres no answer thsus far. My question is, is there
    some sort of way, to easily compress, or reduce my memory requirements
    for this?
    Im planning on adding another 8 maps of this size to the world, and
    8x35megs is not good. Appreciate any help =)
    Cyhawk, Nov 1, 2005
    #1
    1. Advertising

  2. Cyhawk

    Guest

    Cyhawk wrote:
    > Hello. Im working on a game, (mud actually) (socketmud for anyone who
    > cares ;) and ive decided on a very large array to hold my world data.
    > (Nethack style, every cord == number == represents a charater/sector).
    > Im using gzread/gzsave to store/load the array from file, which is
    > nice, im using about 230k disk space when the world is filled. However,
    > in memory its roughly 35megs ([1000][750][11]). Ive googled around, and
    > asked people, and theres no answer thsus far. My question is, is there
    > some sort of way, to easily compress, or reduce my memory requirements
    > for this?
    > Im planning on adding another 8 maps of this size to the world, and
    > 8x35megs is not good. Appreciate any help =)



    This is OT for c.l.c. Try comp.programming.

    OT: You'll probably want some sort of tree or sparse array structure.
    , Nov 1, 2005
    #2
    1. Advertising

  3. Cyhawk

    Malcolm Guest

    "Cyhawk" <> wrote
    > Hello. Im working on a game, (mud actually) (socketmud for anyone who
    > cares ;) and ive decided on a very large array to hold my world data.
    > (Nethack style, every cord == number == represents a charater/sector).
    > Im using gzread/gzsave to store/load the array from file, which is
    > nice, im using about 230k disk space when the world is filled. However,
    > in memory its roughly 35megs ([1000][750][11]). Ive googled around, and
    > asked people, and theres no answer thsus far. My question is, is there
    > some sort of way, to easily compress, or reduce my memory requirements
    > for this?
    > Im planning on adding another 8 maps of this size to the world, and
    > 8x35megs is not good. Appreciate any help =)
    >

    There are all sorts of things you can do.

    Is it really necessary to index every character by world square? Instead of
    the 1000 * 750 (750K min) array, you could have a 100 * 75 array. The
    mainain a linked list in each 10*10 square, into which you put the
    characters.
    Finding a character is rather slower, but is still O(N). At most you can
    have 100 characters to search before you find the right one.
    Malcolm, Nov 1, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wish

    JMF massive memory leak

    wish, Apr 30, 2005, in forum: Java
    Replies:
    0
    Views:
    570
  2. Hallvard B Furuseth

    slowdown with massive memory usage

    Hallvard B Furuseth, Jul 30, 2004, in forum: Python
    Replies:
    5
    Views:
    306
    Bengt Richter
    Aug 1, 2004
  3. Nick Craig-Wood
    Replies:
    1
    Views:
    272
  4. Philipp
    Replies:
    21
    Views:
    1,105
    Philipp
    Jan 20, 2009
  5. Massive Memory Structures

    , Jun 13, 2007, in forum: Perl Misc
    Replies:
    13
    Views:
    180
    Ilya Zakharevich
    Jun 18, 2007
Loading...

Share This Page