RE: Cross-development with Visual Studio
RE: Cross-development with Visual Studio
- Subject: RE: Cross-development with Visual Studio
- From: "Bill Lowrey" <email@hidden>
- Date: Thu, 5 Aug 2004 15:24:51 -0500
- Organization: istation.com
I'm curious: Do you mean to declare a 3D matrix? Or are you trying to
operate with a 2D matrix?
When I compile your code as written, I get a 500K image in RAM, and a crash
on exit.
This is what I have:
#include <cstdio>
template<typename T>
class Vector
{
private:
T *array;
int mCount;
public:
Vector() { array = NULL; mCount=0; };
Vector(int i) { array = new T[i]; mCount=i; };
T &operator[](int i) { return array[i]; };
~Vector() { if(array != NULL) delete [] array; };
};
template<typename M>
class Matrix
{
private:
Vector<M> *matrix;
int mRows;
int mColumns;
public:
Matrix() { mRows=0; mColumns=0; matrix = NULL; };
Matrix(int i, int j)
{
mRows = j;
mColumns = i;
matrix = new Vector<M> [mColumns];
for(int k=0; k<mColumns; ++k)
matrix[k] = Vector<M>(j);
};
Vector<M> &operator[](int i) { return matrix[i]; };
~Matrix() { if(matrix != NULL) delete [] matrix; };
};
Matrix<Vector<float> > fD = Matrix<Vector<float> > (1024, 768);
int main(void)
{
int ch = getchar();
return ch;
}
Regards,
Bill Lowrey
Sr. Software Engineer
istation
-----Original Message-----
From: email@hidden
[mailto:email@hidden] On Behalf Of Raymond Rabu
Sent: Thursday, August 05, 2004 12:45 PM
To: email@hidden
Subject: Cross-development with Visual Studio
I have created a C++ project in Xcode and it seems to run just fine. I load
an image, do some computation and it takes up to 50MB or so of memory while
running.
However, when I compiled the same project in MS Visual Studio, I find that
my memory consumption runs up over 300MB !! Does anyone have any idea why
the same code would behave so differently? I thought C++ was fairly standard
across these compilers (at the level I'm using it anyway).
I've traced it down to this line of code:
Matrix<Vector<float> > fD = Matrix<Vector<float> > (1024, 768);
It seems that allocating this matrix costs lots more under Visual Studio
than under Xcode. Anyone with experience in this have any ideas? I
apologize if I am posting this to the wrong list.
The relevant pieces of the objects here are defined as:
-----------------
template<typename T>
class Vector
{
private:
T *array;
int mCount;
public:
Vector() { array = NULL; mCount=0; };
Vector(int i) { array = new T[i]; mCount=i; };
T &operator[](int i) { return array[i]; };
~Vector() { if(array != NULL) delete [] array; };
};
-----------------
template<typename M>
class Matrix
{
private:
Vector<M> *matrix;
int mRows;
int mColumns;
public:
Matrix() { mRows=0; mColumns=0; matrix = NULL; };
Matrix(int i, int j)
{
mRows = j;
mColumns = i;
matrix = new Vector<M> [mColumns];
for(int k=0; k<mColumns; ++k)
matrix[k] = Vector<M>(j);
};
Vector<M> &operator[](int i) { return matrix[i]; };
~Matrix() { if(matrix != NULL) delete [] matrix; };
};
------------------
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.