Help, i need more memory from the heap!!!

Discussion in 'C++' started by laclac01@yahoo.com, Aug 16, 2005.

  1. Guest

    I am developing on windows XP professional, with 512 Megs of ram,
    writing a console program in MSVC++ 6.0. I am writing a program that
    processes very large matrixes. I am using a library that to do all the
    matrix manipulations. But unfortunately at some point in my program
    the matrixes are so large that I run out of memory.(I get an error
    saying unable to allocate anymore memory) For what I am doing, I
    can't break the matrixes down; they have to be kept as is. So my
    question is there a way I can increase the size of the heap that is
    given to me by windows? I am assuming windows allocates X amount of
    memory for me to be able to use.
    , Aug 16, 2005
    #1
    1. Advertising

  2. wrote:
    > I am developing on windows XP professional, with 512 Megs of ram,
    > writing a console program in MSVC++ 6.0. I am writing a program that
    > processes very large matrixes. I am using a library that to do all the
    > matrix manipulations. But unfortunately at some point in my program
    > the matrixes are so large that I run out of memory.(I get an error
    > saying unable to allocate anymore memory) For what I am doing, I
    > can't break the matrixes down; they have to be kept as is. So my
    > question is there a way I can increase the size of the heap that is
    > given to me by windows? I am assuming windows allocates X amount of
    > memory for me to be able to use.


    Please ask platform-specific questions in newsgroups for the respective
    platforms. 'comp.os.ms-windows.programmer.win32' is what you need for
    this particular inquiry.
    Victor Bazarov, Aug 16, 2005
    #2
    1. Advertising

  3. Frank Chang Guest

    I am curious how you are allocating memory for your matrix. Are you
    using a
    double** matrix member variable where the pointer to pointer allows you
    to first, allocate memory to a pointer to the row and second,
    allocate memory for the columns in each row?

    But the most important thing I have found when I came across this
    problem is to try to exploit the symmetry in your matrix to reduce the
    actual number of memory elements you have to allocate memory for.
    Also, please try using linear algebra algorithms to process smaller
    chunks of your matrix at one time. Then , at the end , you can
    aggregate the results from each processing each chunk of the matrix.
    This is sometimes done in digital signal processing.
    Frank Chang, Aug 16, 2005
    #3
  4. Frank Chang Guest

    In addition, if you can't really decompose your matrix using LA (don't
    forget there is a ton of research out there which addresses your very
    problem. The answer you get may not be perfect but an approximation)
    why are you constrained to 512 MB. RAM Is relatively inexpensive and
    you can expand to 2GB RAM with Windows XP.
    The vast majority of matrices have symmetry. You just have to look
    real hard to find it.
    Finally, Microsoft has recently come out with a 64 bit version of
    Windows 2003 . That should give you a lot more memory to use for your
    problem. The problem is that 32 bit Windows software will not
    automatically port to 64 bit Windows machines.
    Frank Chang, Aug 16, 2005
    #4
  5. Guest

    I am using a library from C/math tool chest. It does complex numbers.
    Is there a library you can recomend other than this one? This one is
    kind of old.
    , Aug 16, 2005
    #5
  6. Frank Chang Guest

    lacla...., Sorry I don't even know your first name. Here is a Matrix
    class that I just wrote. Is this what you are using for your matrix?

    class Matrix
    {
    private:
    int rows;
    int columns;
    double **m;

    public:
    class Matrix1D{
    public:
    Matrix1D(int row, Matrix& matrix)
    : id(row),
    aMatrix(matrix)
    {}

    double& operator[](int index)
    {
    return aMatrix.m[id][index];
    }

    ~Matrix1D()
    {
    //some stufff
    }

    private:
    int id;
    Matrix& aMatrix;
    };

    Matrix(int i, int j)
    : rows(i), columns(j)
    {
    m = new double*[rows];
    for (int r = 0; r < rows; r++)
    m[r] = new double[columns];
    for (int u = 0; u < rows; u++)
    {
    for (int v = 0; v < columns; v++)
    m[v] = 0.0;
    }
    }


    Matrix(const Matrix& theMatrix)
    {
    for (int i = 0; i < theMatrix.rows; i++)
    delete [] m;
    delete [] m;

    m = new double*[theMatrix.rows];
    for (int ii = 0; ii < theMatrix.rows; ii++)
    m[ii] = new double[theMatrix.columns];

    for (int jj = 0; jj < theMatrix.rows; jj++)
    {
    for (int kk = 0; kk < theMatrix.columns; kk++)
    m[jj][kk] = theMatrix.m[jj][kk];
    }
    }


    ~Matrix()
    {
    for (int k = 0; k < rows; k++)
    delete [] m[k];
    delete [] m;
    }

    Matrix1D operator[](int row)
    { return Matrix1D(row, const_cast<Matrix&>(*this)); }

    friend class Matrix1D;
    };

    As for your question about the Complex library, maybe you can find the
    answer if you post in another newsgroup, as Victor Bazarov suggested.
    Frank Chang, Aug 16, 2005
    #6
    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. Michael
    Replies:
    4
    Views:
    397
    Matt Hammond
    Jun 26, 2006
  2. Replies:
    3
    Views:
    325
    Keith Thompson
    Dec 17, 2006
  3. Michal Slocinski

    Heap dump file size vs heap size

    Michal Slocinski, Mar 25, 2008, in forum: Java
    Replies:
    1
    Views:
    717
    GArlington
    Mar 25, 2008
  4. viki
    Replies:
    6
    Views:
    554
    Erik Wikström
    Jun 28, 2008
  5. Raymond Schanks
    Replies:
    0
    Views:
    500
    Raymond Schanks
    Apr 11, 2010
Loading...

Share This Page