473,666 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

heap status

Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????

if my memory is correct in the old turbo c++ 3.0 compiler there were
some macros by name _HEAPOK, _HEAPEMPTY, and
_HEAPCORRUPT , is there something similar to this in standard C.????
Nov 22 '07 #1
13 3258
aa*****@gmail.c om wrote:
Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????
Do you only read replies to your postings? We've recently pointed out
(once again) that C doesn't care about heaps, stacks or segments.

So the answer is simply - no. There may be a way with the implementation
you are using on a specific platform, but that is not part of the C
standard. You could ask on a newgroup which discusses the C
implementation and/or platform you are using.

By the way - as I understand it the standard is an ISO standard which
has been adopted by ANSI, so the "or" in your question is irrelevant.
Nov 22 '07 #2
aa*****@gmail.c om wrote:
Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????

if my memory is correct in the old turbo c++ 3.0 compiler there were
some macros by name _HEAPOK, _HEAPEMPTY, and
_HEAPCORRUPT , is there something similar to this in standard C.????
No.
Nov 22 '07 #3
aa*****@gmail.c om wrote:
Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????
No.

What do you think "the status of the heap" means [I assume that
by "the heap" you mean the memory managed by malloc and friends],
and what would you do with the status if you had it?

--
Heaped Highly Hedgehog
"We did not have time to find out everything we wanted to know."
- James Blish, /A Clash of Cymbals/

Nov 22 '07 #4
On Nov 22, 1:15 pm, Chris Dollin <e...@electrich edgehog.netwrot e:
aark...@gmail.c om wrote:
Hi all,
Is there a possible way to check the status of heap in ANSI-C
or standard C....????

No.

What do you think "the status of the heap" means [I assume that
by "the heap" you mean the memory managed by malloc and friends],
and what would you do with the status if you had it?

--
Heaped Highly Hedgehog
"We did not have time to find out everything we wanted to know."
- James Blish, /A Clash of Cymbals/
I just saw a program in an old turbo c text as follows

#include<stdio. h>
#include<malloc .h>
#include<alloc. h>

main()
{
char *ch;
if(heapcheck() == _HEAPOK)
{
puts("Heap is correct");
ch = (char*) malloc(100);
gets(ch);
puts(ch);
free(ch);
getch();
}
else
{
puts("heap is corrupt");
puts("Press any key to exit");
exit(1);
}

}
Nov 22 '07 #5
Chris Dollin wrote:
aa*****@gmail.c om wrote:
>Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????

No.

What do you think "the status of the heap" means [I assume that
by "the heap" you mean the memory managed by malloc and friends],
and what would you do with the status if you had it?
Debug programs which have memory allocation problems. I've used
instrumented versions of the malloc() family for precisely this purpose,
with modest success.
Nov 22 '07 #6
In article <65************ *************** *******@d21g200 0prf.googlegrou ps.com>,
<aa*****@gmail. comwrote:
>I just saw a program in an old turbo c text as follows
[...]
if(heapcheck() == _HEAPOK)
{
puts("Heap is correct");
Apart from the unportability, the use of such things is limited, since
if the heap has been corrupted it's quite possible that puts() won't
work, even if the program gets that far. What's more, it only detects
memory errors that corrupt the heap structures. For most situations,
I recommend testing your program extensively with an external checker
such as valgrind.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 22 '07 #7
aa*****@gmail.c om wrote:
Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????

if my memory is correct in the old turbo c++ 3.0 compiler there were
some macros by name _HEAPOK, _HEAPEMPTY, and
_HEAPCORRUPT , is there something similar to this in standard C.????
Microsoft provides a lot of functions to debug the heap
Look into
http://msdn2.microsoft.com/en-us/lib...37(VS.71).aspx

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Nov 22 '07 #8
>aa*****@gmail.c om wrote:
>>Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????
>Chris Dollin wrote:
>No.

What do you think "the status of the heap" means [I assume that
by "the heap" you mean the memory managed by malloc and friends],
and what would you do with the status if you had it?
In article <iTj1j.15980$Xg .6107@trnddc06>
James Kuyper <ja*********@ve rizon.netwrote:
>Debug programs which have memory allocation problems. I've used
instrumented versions of the malloc() family for precisely this purpose,
with modest success.
Indeed. As I like to put it, using an invalid pointer value, such
as:

#include <stdlib.h>
#include <string.h>

char *buggy_dupstr(c onst char *str) {
return strcpy(malloc(s trlen(str)), str); /* two bugs in one! */
}

can "plant a time bomb" in the runtime system. Having some way
to "make the bomb go off sooner" can be helpful in locating the
code that planted it.

Or, of course, one can use a system that has "fat pointers", where
the error is trapped even sooner. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 23 '07 #9
On Nov 22, 9:06 pm, aark...@gmail.c om wrote:
Hi all,

Is there a possible way to check the status of heap in ANSI-C
or standard C....????

if my memory is correct in the old turbo c++ 3.0 compiler there were
some macros by name _HEAPOK, _HEAPEMPTY, and
_HEAPCORRUPT , is there something similar to this in standard C.????
It is available with Microsoft Visual C++ and not with C.

Karthik Balaguru
Nov 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5877
by: ANt | last post by:
Hi, we have some major GC issues at present with a system we're trying to put live. It's a live calculation engine that's distributed across about 30 Java server processes. A set of processes called objectservers sit between the core infra and a Sybase DB. Two of the main objectservers are set up with 2Gb Heaps as they need to cache large amounts of objects and accept 500-600 incoming RMI connections when heavily loaded. We're running the...
1
2583
by: Dave Dons | last post by:
GCC 3.3.4 setting Stack and Heap Help appreciated setting stack (and heap) in GCC in Linux: gcc (GCC) 3.2.3 (mingw special 20030504-1) has no problems with: g++ -Wl,--heap,1048576,--stack,10485760 axx1.cpp utils.cpp -Wall -Os -o axxngcc g++ -Wl,--heap=1048576,--stack=10485760 axx1.cpp utils.cpp -Wall -Os -o axxgcc g++ -Wl,--heap=0x00100000,--stack=0x00A00000 axx1.cpp -Wall -Os -o
0
3425
by: Erik Hendrix | last post by:
Hi, I was wondering if someone maybe knew what is stored in the following memory array and maybe give a clue as in why it is not released anymore: I have 1 agent which reports the following using pmap: # "pmap -x 9659 9659: db2sysc Address Kbytes Resident Shared Private Permissions Mapped File
16
4438
by: sarathy | last post by:
Hi all, I need a few clarifications regarding memory allocaion in C++. I apologize for the lengthy explanation. 1. In C++, Objects are allocated in heap. What does heap refer to? Is it an area in RAM/Memory or does it refer to a data structure being used for storing objects. 2. In C++, functions and its local variables go in stack. If local variables that are primitives go in stack, it is OK. But what
53
26363
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global variable? My answer: static variable in function and global variable are allocated in head, and automatic variable is allocated in stack. Right?
7
4649
by: gnanapoongothai | last post by:
hi, the error i am getting in main for allocating heap memory for threads is #include <stdio.h> #include "winsock2.h" #include <stdlib.h> #include <windows.h> #include <strsafe.h> #define BUF_SIZE 255 #define nofthreads 2
5
24706
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 (I am new to Windows so not sure). We are currently bouncing the instance to overcome this error. This generally happen at the end of business day only (So maybe memory might be getting used up?). We have already increased the statement heap & ...
4
9581
by: ggoubb | last post by:
The purpose of the Insert function is to add a new integer in the Heap assuming that it is not already full. If Heap capacity has been reached, it attempts to double the current capacity. If capacity cannot be doubled, it throws FullHeap. Here is the Heap.h file const int MAXSIZE = 4; // Default maximum heap size class Heap // Smart Heap ADT as an array { private: int* ptr; ...
0
8448
marktang
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...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
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...
0
8783
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 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...
1
8552
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,...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5666
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();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
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 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.