Hello
I am using a subroutine to solve relatively large matrix in C++
but I got an error with this text
"The exception unknown software exception (0x0000005) occurred in the application at location 0x0040a97a"
I know that this is an error in memory allocation. my computer has 16GB RAM memory. but I dont know how to use it to solve a matrix greater than 10000x10000.
right now I can not solve matrices greater than 4000x4000.
I appreciate anyone help me
Thanks
Reza
10 1883 gpraghuram 1,275
Recognized Expert Top Contributor
Hello
I am using a subroutine to solve relatively large matrix in C++
but I got an error with this text
"The exception unknown software exception (0x0000005) occurred in the application at location 0x0040a97a"
I know that this is an error in memory allocation. my computer has 16GB RAM memory. but I dont know how to use it to solve a matrix greater than 10000x10000.
right now I can not solve matrices greater than 4000x4000.
I appreciate anyone help me
Thanks
Reza
Are you allocating memory for this statically or dynamically?
Raghuram
Are you allocating memory for this statically or dynamically?
Raghuram
I am allocating memory dynamically by pointers.
Let's see your allocation.
And what operating system are you using??
And what compiler??
the operating system is windows xp and compiler is C++
is there any way that I specify the amount of memory which should be used?
I mean because my computer has 16 GB RAM but I am sure that I am not using it.
thanks
Savage 1,764
Recognized Expert Top Contributor
the operating system is windows xp and compiler is C++
is there any way that I specify the amount of memory which should be used?
I mean because my computer has 16 GB RAM but I am sure that I am not using it.
thanks
Windows Xp can't make use of that RAM amount,maximum it can use is 3.5GB.You will need to install Windows Vista x64(Win Xp x64 for some reason also only uses 3.5GB of RAM).
Also how are you solving those matrices,with recursion?
If so it's no wonder you couldn't solve matrix that big.It takes a lot of space even if you make every entry to be a 1B char.
Savage
I am using LU decomposition to solve it.
the operating system is xp 64.
is there any way to make the program to work?
Reza2: You still haven't shown me your code for your allocation.
The memory you allocate has nothing to do woth the memory in your computer. Check out the section on Memory Management in Windows via C/C++ by Jeffrey Richter 2008.
I have attached the solver part of my code.
you can see its error.
matrix size is 10000x1000.
#include<math.h >
#include<fstrea m.h>
#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>
#include <iomanip.h>
#include <stdio.h>
#include <time.h>
#include <malloc.h>
#include <stdio.h>
#include <math.h>
//************* INPUT Data *************** *************** *************** *************** ********
const int Nx=100; // no. of fine scale grid in x direction
const int Ny=100; // no. of fine scale grid in y direction
//*************** *********** Variables Arrays *************** *************** ***********
double **a,**l,**u,*b, *x;
int i,j,k,n;
//*************** ************** Subroutines and Functions *************** *************** *******/
void linbcg(unsigned long n, double b[], double x[], int itol, double tol,
int itmax, int *iter, double *err);
void solver(double **a,double **u,double **l, double *b,int n,int N); // Solver subroutine
int min(int r,int s); //
int max(int r,int s);
void main()
{
//*************** ***** Matrix Decleration *************** *************** *************** *********
n=Nx*Ny;
b=new double [n+1];
x=new double [n+1];
a=new double *[n+1];
l=new double *[n+1];
u=new double *[n+1];
for(i=0;i<=n;i+ +){
a[i]=new double [n+1];
l[i]=new double [n+1];
u[i]=new double [n+1];
}
//********* a[][]*************** ** adjacency matrix
for(j=1;j<=n;j+ +)
for(i=1;i<=n;i+ +)
a[i][j]=0.0;
j=1;
for(i=1;i<=Nx;i ++){
k=Nx*(j-1)+i;
a[k][k]=4.9;
}
for(j=2;j<Ny;j+ +)
for(i=1;i<=Nx;i ++){
k=Nx*(j-1)+i;
a[k][k]=5;
}
j=Ny;
for(i=1;i<=Nx;i ++){
k=Nx*(j-1)+i;
a[k][k]=4.9;
}
for(j=1;j<=Ny;j ++)
for(i=1;i<Nx;i+ +){
k=Nx*(j-1)+i;
a[k][k+1]=2.2;
}
for(j=1;j<=Ny;j ++)
for(i=2;i<=Nx;i ++){
k=Nx*(j-1)+i;
a[k][k-1]=2.2;
}
for(j=1;j<=Ny-1;j++)
for(i=1;i<=Nx;i ++){
k=Nx*(j-1)+i;
a[k][k+Nx]= 2.4;
}
for(j=2;j<=Ny;j ++)
for(i=1;i<=Nx;i ++){
k=Nx*(j-1)+i;
a[k][k-Nx]=2.4;
}
ofstream matrixA("A.dat" ,ios::in);
for (j=1;j<=n;j++)
{
for (i=1;i<=n;i++)
{
matrixA<<a[i][j]<<" \t";
}
matrixA<<"\n";
}
//*************** *****b[]********** Forcing function matrix *************** *************
for(j=1;j<=Ny;j ++)
for(i=1;i<=Nx;i ++){
k=Nx*(j-1)+i;
b[k]=(0.0);
}
i=1;
for(j=1;j<=Ny;j ++)
{
k=Nx*(j-1)+1;
b[k]= 6;
}
i=Nx;
for(j=1;j<=Ny;j ++)
{
k=Nx*(j-1)+Nx;
b[k]= 1;
}
//********** solver *************** *************** ***************
solver(a,u,l,b, n,Nx);
for(j=1;j<=Ny;j ++)
for(i=1;i<=Nx;i ++)
{
k=Nx*(j-1)+i;
x[k]=b[k];
}
for(j=1;j<=Ny;j ++)
for(i=1;i<=Nx;i ++)
{
k=Nx*(j-1)+i;
cout<<"x("<<k<< ","<<i<<","<<j< <"]="<<x[k]<<endl;
}
}
//*************** *************** *************** *************** *************** *************** *******
//*************** ******** subroutin Matrix solver *************** *************** *********
void solver(double **a,double **u,double **l, double *b,int n,int N)
{
int i,j,k,mi,mx;
double zig,sig;
int p=N+1; int q=N+1;
//******* LU decomposition *************** ******
for(k=1;k<=n-1;k++){
mi=min(k+p,n);
for(i=k+1;i<=mi ;i++)
a[i][k]=a[i][k]/a[k][k];
for(i=k+1;i<=mi ;i++){
mi=min(k+q,n);
for(j=k+1;j<=mi ;j++)
a[i][j]=a[i][j]-a[i][k]*a[k][j];
}
}
for(i=1;i<=n;i+ +)
for(j=1;j<=n;j+ +){
l[i][j]=0.0;
u[i][j]=0.0;
}
/// matrix L[][] ////
for(i=1;i<=n;i+ +){
for(j=1;j<i;j++ )
l[i][j]=a[i][j];
}
//////matrix U[][] //////////////
for(i=1;i<=n;i+ +){
for(j=i;j<=n;j+ +)
u[i][j]=a[i][j];
}
///// overwriting b[] for L[][] matrix
for(i=1;i<=n;i+ +){
mx=max(1,i-p);
zig=0.0;
for(j=mx;j<=i-1;j++)
zig=zig+l[i][j]*b[j];
b[i]=b[i]-zig;
}
/// solution matrix x[] for UX=Y
for(i=n;i>=1;i--){
mi=min(i+q,n);
sig=0.0;
for(j=i+1;j<=mi ;j++)
sig=sig+u[i][j]*b[j];
b[i]=(b[i]-sig)/u[i][i];
}
}
int min(int r,int s){
int mini=0;
mini=r;
if(s<r) mini=s;
return mini ;
}
int max(int r,int s){
int mxi=0;
mxi=r;
if(s>r) mxi=s;
return mxi;
}
if you know how can I debug it just let me know.
Thanks
Savage 1,764
Recognized Expert Top Contributor
Are you freeing this memory?
Savage
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I'm not sure how this is normally done, on a large site, perhaps one
running Phorum. Occassionally a thread will have hundreds of entries,
perhaps a meg or two worth of data. You won't necessarily print all
that to the screen, but PHP has to hold it in memory. Run some
operations on it, or, more likely, have an array that you keep adding
things to, and very soon you run into the 8 meg limit that is the
default limit for PHP scripts.
...
|
by: Mark D. Anderson |
last post by:
About a month ago Richard Cornford did an interesting analysis of a
memory leak
in jscript (internet explorer) when there are "circular" references
between
DOM objects and (real) jscript objects:
http://groups.google.com/groups?selm=bcq6fn%24g53%241%248300dec7%40news.demon.co.uk
This message summarizes some testing I've done and their results.
These results somewhat contradict Cornford's conclusions; I haven't
|
by: Bikash |
last post by:
Hello,
I am a specific problem in exception handling. The code snippets is
attached below.
void f()
{
char *ptr = new char(20);
throw 2;
}
|
by: Ian |
last post by:
I have and Access 97 DB that prints a report that has many pages, sometime
about 800-1000 page, each page contains a colour picture along with text
boxes.
The pictures are displayed on the report but the DB only stores the path to
the picture. On the reports detail sections On Print event I have the code
(.Picture = ). Image path is the field that store the
picture location.
My problem is that when I send this report to the printer,...
|
by: boss_bhat |
last post by:
Hi all ,
I am beginner to C programming. I have a defined astructure like the
following, and i am using aliases for the different data types in the
structure,
typedef struct _NAME_INFO {
struct _NAME_INFO *Next;
ULONG LastId;
ULONG Id;
PVOID Value;
| |
by: Giovanni Boschi |
last post by:
We have found a memory leak when using a COM library with a C# application.
The leak appears only if the C# application is compiled with the /optimize
flag. It goes away when the C# application is compiled with the /debug flag.
The COM library is coded to fire asynchronous events, which are handled by
the C# application. It is in the firing and handling of these events that
the leak occurs.
Why does the optimized application leak while...
|
by: syang8 |
last post by:
hi, folks,
I use Kdevelop to build some scientific simulation on Linux. If I set
the size of an array N = 8000, the program works fine. However, if I
set the array N some number greater than 10000 (actually, what I need
is 80000), the program has segmentation error. The intersting thing is
that the positions reporting segmentation error are different if I set
N to be different values.
What problem is this usually? I guess must be...
|
by: frederic.pica |
last post by:
Greets,
I've some troubles getting my memory freed by python, how can I force
it to release the memory ?
I've tried del and gc.collect() with no success.
Here is a code sample, parsing an XML file under linux python 2.4
(same problem with windows 2.5, tried with the first example) :
#Python interpreter memory usage : 1.1 Mb private, 1.4 Mb shared
#Using http://www.pixelbeat.org/scripts/ps_mem.py to get memory
information
|
by: George2 |
last post by:
Hello everyone,
Should I delete memory pointed by pointer a if there is bad_alloc when
allocating memory in memory pointed by pointer b? I am not sure
whether there will be memory leak if I do not delete a.
try {
a = new int ;
|
by: George2 |
last post by:
Hello everyone,
Such code segment is used to check whether function call or exception-
handling mechanism runs out of memory first (written by Bjarne),
void perverted()
{
try{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |