Hi,
While New() is used for allocating objects on heap some additional
information is stored before the begning of the block so that delete can
release the allocated memory.
Any idea what this information is just the size or anything else also ? is
it dependent on the compiler used ?
Regards,
Gaurav 7 1191
Gaurav Jain wrote: Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ? is it dependent on the compiler used ?
Not only the information itself, but also the place where it is stored
depends on the compiler and the library implementation.
What this information may be ?
"Rolf Magnus" <ra******@t-online.de> wrote in message
news:d8*************@news.t-online.com... Gaurav Jain wrote:
Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ?
is it dependent on the compiler used ?
Not only the information itself, but also the place where it is stored depends on the compiler and the library implementation.
"Gaurav Jain" <my*******@yahoo.com> wrote in message
news:d8********@netnews.proxy.lucent.com... Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ? is it dependent on the compiler used ?
Regards, Gaurav
I assume you mean "new"? There is no "New" defined in C++.
And yes, it's compiler-dependent what information gets stored. And where.
There is no requirement that such information be stored at any particular
place.
-Howard
"Gaurav Jain" <my*******@yahoo.com> skrev i en meddelelse
news:d8********@netnews.proxy.lucent.com... Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ? is it dependent on the compiler used ?
Regards, Gaurav
Why should you store anything besides the object? This is not necessary in
the general case. Perhaps you are thinking about new[] where the application
MIGHT store the number of elements allocated. But again, there's no need to
store anything.
/Peter
"Peter Koch Larsen" <pk*****@mailme.dk> wrote in message
news:QT********************@news000.worldonline.dk ... "Gaurav Jain" <my*******@yahoo.com> skrev i en meddelelse news:d8********@netnews.proxy.lucent.com... Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ? is it dependent on the compiler used ?
Regards, Gaurav
Why should you store anything besides the object? This is not necessary in the general case. Perhaps you are thinking about new[] where the application MIGHT store the number of elements allocated. But again, there's no need to store anything.
/Peter
When freeing memory, even for a single object, the amount of memory
originally allocated needs to be known (by something, somewhere), in order
to restore the right amount of memory to the system. And that applies even
at the low level of malloc/free, not just new/delete. How such information
is kept is not specified by the standard, however. Some OS or hardware may
handle such details for you. It's not something that, at least in general,
a C++ programmer should bother worrying about.
To the OP: why are you asking? Is there a problem you're trying to resolve,
or just curious?
-Howard
Gaurav Jain wrote: "Rolf Magnus" <ra******@t-online.de> wrote in message news:d8*************@news.t-online.com... Gaurav Jain wrote:
Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ? is it dependent on the compiler used ? Not only the information itself, but also the place where it is stored depends on the compiler and the library implementation.
What this information may be ?
Please don't top-post. Your reply belongs following or interspersed
with the quoted material.
That information is completely outside the realm of the user. What
information and where it is kept is implementation-specific and is not
topical here. If you really must know, you'll need to find a newsgroup
dedicated to your platform (compiler/OS).
Brian
"Howard" <al*****@hotmail.com> skrev i en meddelelse
news:j5*********************@bgtnsc04-news.ops.worldnet.att.net... "Peter Koch Larsen" <pk*****@mailme.dk> wrote in message news:QT********************@news000.worldonline.dk ... "Gaurav Jain" <my*******@yahoo.com> skrev i en meddelelse news:d8********@netnews.proxy.lucent.com... Hi,
While New() is used for allocating objects on heap some additional information is stored before the begning of the block so that delete can release the allocated memory.
Any idea what this information is just the size or anything else also ? is it dependent on the compiler used ?
Regards, Gaurav
Why should you store anything besides the object? This is not necessary in the general case. Perhaps you are thinking about new[] where the application MIGHT store the number of elements allocated. But again, there's no need to store anything.
/Peter
When freeing memory, even for a single object, the amount of memory originally allocated needs to be known (by something, somewhere), in order to restore the right amount of memory to the system. And that applies even at the low level of malloc/free, not just new/delete.
[snip]
Correct. But that does not imply that the size needs to be explicitly stored
anywhere. Most likely it will not be, unless it is a "large" object.
-Howard
/Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kk |
last post by:
Hi all,
i didn't get output in the following code while compiling and executing
with g++ version 3.2.3 it doesn't allocate memory to pointer varaible
(x) in class B. and it gives correct output...
|
by: chris |
last post by:
Hi all,
I need to know, what is the difference between dynamic memory
allocation, and stack allocation ?
1. If I have a class named DestinationAddress, when should I use
dynamic memory...
|
by: PaulR |
last post by:
Hi,
We have a Server running SLES 8 and 3GB memory, with 1 DB2 instance and
2 active Databases.
General info...
DB2level = "DB2 v8.1.0.72", "s040914", "MI00086", and FixPak "7"
uname -a =...
|
by: ballpointpenthief |
last post by:
If I have malloc()'ed a pointer and want to read from it as if it were
an array, I need to know that I won't be reading past the last index.
If this is a pointer to a pointer, a common technique...
|
by: ivan.leben |
last post by:
How can I really delete a preloaded image from memory/disk cache? Let's
say I preload an image by creating an Image object and setting its src
attribute to desired URL:
var img = new Image();...
|
by: Johan Tibell |
last post by:
I've written a piece of code that uses sockets a lot (I know that
sockets aren't portable C, this is not a question about sockets per
se). Much of my code ended up looking like this:
if...
|
by: Ken |
last post by:
In C programming, I want to know in what situations we should use
static memory allocation instead of dynamic memory allocation. My
understanding is that static memory allocation like using array...
|
by: Peterwkc |
last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back.
By the way, my problem is like this i the first program was...
|
by: krishna81m |
last post by:
In the following code, I am trying to return a char, a char* (a type of non-const without using new, what do we call this type of pointer?) and char* created using new operator. What I do not know at...
|
by: karthikbalaguru |
last post by:
Hi,
Will 'free' return the memory Immediately to the OS ?
Thx in advans,
Karthik Balaguru
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |