473,509 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reg memory error

22 New Member
Hi All,

I m creating one exe using C programing and i m facing one issue in this.
I defined an array which size was 1024 (like SortOnPrimarySol[1024] )Now i want to increase this size to more than this 1024.

While increasing the size as more than 1035, the exe is creating but while execiting this exe, its giving me memory reference error.
If i will decrease this size to 1030 and again create this exe and run this exe then it is working fine.

Can any one let me know what is the prob while i m giving array size as more than 1030???? and why?? is thr any limitation ??
How can i overcome from this issue???

Plaese let me know.

Thanks in advance,
Sharique
Oct 23 '07 #1
2 1214
Banfa
9,065 Recognized Expert Moderator Expert
That is rather dependent on the platform you are using. However if this variable is being placed on the stack (has auto scope) then you need to change you code structure. It is inadvisable to put so much data on the stack.

Giving the array count doesn't really help without knowing the type, how much data are you actually trying to allocate?

There is no syntactic reason for an array to be limited to 1030 entries, the limiting factor is memory.
Oct 23 '07 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
While increasing the size as more than 1035, the exe is creating but while execiting this exe, its giving me memory reference error.
If i will decrease this size to 1030 and again create this exe and run this exe then it is working fine.

Can any one let me know what is the prob while i m giving array size as more than 1030???? and why?? is thr any limitation ??
How can i overcome from this issue???
You create your array on the heap whwere you can specify the number of elements at run time.
To expand the array:
1) create a new array on the heap of the new size
2) copy the original array into new array
4) delete the pointer to the original array
5) put the address of the new array into the pointer to the original array

I would do this inside a function that takes the address of the pointer tio the original array. Here is one assuming an array of int:
Expand|Select|Wrap|Line Numbers
  1. void ExpandArray(intr** arr, int newsize)
  2. {
  3.      int* temp = new int[newsize]
  4.      //TODO: copy arr array to temp array
  5.     delete *arr;   //delete original array
  6.     *arr = temp;  //put new array address into pointer to original array
  7. }
  8.  
When the function returns the original array has been expanded.
Oct 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4358
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
1
4344
by: Attila.Rajmund.Nohl | last post by:
Hello! I'm using KAI C++ Compiler (KCC) Version 4.0d on Sparc Solaris 8 with Sun WorkShop 6 update 2 backend (KCC compiles C++ code to C than uses the Sun compiler to produce machine...
6
2279
by: Andrzej | last post by:
Used to read newsgroup for answers, now have to ask for them as well. I have an application (C#, .NET 1.1) that connects to local db on MSDE 2000 SP3a (using ADO from MDAC 2.71) on one side and...
25
2346
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
4
5968
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over...
2
3797
by: saran | last post by:
I am having a problem with MySQL consuming a lot of memory and eventually throwing an Out of Memory error and restarting itself. The symptoms are that swap usage continues to rise until some...
6
4144
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
5
24599
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS...
27
2919
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...
2
3294
by: ravishi | last post by:
Well, this is my first topic at this forum and I'm a newbie on C programming too. I'm coding a little program and I've used some "dynamic arrays" on it. Compiling and running the program on Linux...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7416
jinu1996
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...
1
7073
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...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
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,...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.