Hi,
if I allocate memory in a simple program like
int* pint1=new[1000];
int* pint2=new[1000];
int* pint3=new[1000];
then memory is allocated on the heap. My question is if this three
"memory fragmetns" are allocated contigously. And if not, what could I
do to allocate them contigously.
Thanks 6 1560
On Oct 18, 11:55 pm, horacius....@gmail.com wrote:
Hi,
if I allocate memory in a simple program like
int* pint1=new[1000];
int* pint2=new[1000];
int* pint3=new[1000];
then memory is allocated on the heap. My question is if this three
"memory fragmetns" are allocated contigously. And if not, what could I
do to allocate them contigously.
Thanks
1). They might be allocated contigously but this is not always
guaranteed.
2). Honestly I'm not quite clear about this point, I think you might
need to define your own memory allocation strategy, using some
"placement new operator" or something...
Regards,
-robin
On Oct 18, 8:55 pm, horacius....@gmail.com wrote:
Hi,
if I allocate memory in a simple program like
int* pint1=new[1000];
int* pint2=new[1000];
int* pint3=new[1000];
then memory is allocated on the heap. My question is if this three
"memory fragmetns" are allocated contigously. And if not, what could I
do to allocate them contigously.
Thanks
hey
im sure sbout that memory may not be contiguous....since it is done
dynamically...rather never..coz u can take that probability as
1:trillion.
and about the thing im not 140% sure is that nthng can be done about
it...only thing u can do is that u can join them by linking stacks..
well thats all i know frm my school... ;)...im still studying..pl tell
me if there;s a mistake
On Oct 18, 12:04 pm, farb...@gmail.com wrote:
On Oct 18, 8:55 pm, horacius....@gmail.com wrote:
Hi,
if I allocate memory in a simple program like
int* pint1=new[1000];
int* pint2=new[1000];
int* pint3=new[1000];
then memory is allocated on the heap. My question is if this three
"memory fragmetns" are allocated contigously. And if not, what could I
do to allocate them contigously.
Thanks
hey
im sure sbout that memory may not be contiguous....since it is done
dynamically...rather never..coz u can take that probability as
1:trillion.
and about the thing im not 140% sure is that nthng can be done about
it...only thing u can do is that u can join them by linking stacks..
well thats all i know frm my school... ;)...im still studying..pl tell
me if there;s a mistake
y do people talk lik thiz. I mean seriously people. Is it that hard
to communicate using complete words? To me, it topples your
credibility.
Okay, now for something that really matters. Will the data be
contigously? Maybe. Maybe not. How to make them contigous: Here's
what I would do.
int* pint=new[3000];
int* pint1 = pint;
int* pint2 = pint + 1000;
int* pint3 = pint + 2000;
On Oct 18, 4:55 pm, horacius....@gmail.com wrote:
Hi,
if I allocate memory in a simple program like
int* pint1=new[1000];
int* pint2=new[1000];
int* pint3=new[1000];
then memory is allocated on the heap. My question is if this three
"memory fragmetns" are allocated contigously. And if not, what could I
do to allocate them contigously.
No - there is almost certainly going to be some extra
stuff before each block which prevents them being
contiguous. To ensure contiguity, you could do this:
int* p1 = new int[3000];
int* p2 = p1 + 1000;
int* p3 = p2 + 1000;
Obviously in this case you must be sure to only
delete[] the p1 pointer.
But why do you care about contiguity ?
GameboyHippo <ja************@gmail.comwrote:
Okay, now for something that really matters. Will the data be
contigously? Maybe. Maybe not. How to make them contigous: Here's
what I would do.
int* pint=new[3000];
int* pint1 = pint;
int* pint2 = pint + 1000;
int* pint3 = pint + 2000;
That would work, I'd make pint a vector<intthough instead.
if I allocate memory in a simple program like
>
int* pint1=new[1000];
int* pint2=new[1000];
int* pint3=new[1000];
then memory is allocated on the heap. My question is if this three
"memory fragmetns" are allocated contigously. And if not, what could I
do to allocate them contigously.
int *bigfatpint = new int[3000];
int *pint1 = bigfatpint;
int *pint2 = bigfatpint + 1000;
int *pint3 = bigfatpint + 2000;
cheers,
Marcin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andreas Suurkuusk |
last post by:
Hi,
I just noticed your post in the "C# memory problem: no end for our problem?"
thread.
In the post you implied that I do not how the garbage collector works and
that I mislead people. Since...
|
by: Mike Peretz |
last post by:
I am trying to optimize my C# program, but no matter what I try the
application keeps eating memory. I verified all the references and even got
special software to count references. I made sure all...
|
by: Mike P |
last post by:
I know everything about reference counting and making sure you don't have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but...
|
by: xixi |
last post by:
hi, we are using db2 udb v8.1 for windows, i have changed the buffer
pool size to accommadate better performance, say size 200000, if i
have multiple connection to the same database from...
|
by: Alessandro Monopoli |
last post by:
Hi all,
I'm searching a PORTABLE way to get the available and total physical memory.
Something like "getTotalMemory" and it returns the memory installed on my PC
in bytes, and...
|
by: Nick Craig-Wood |
last post by:
I've been dumping a database in a python code format (for use with
Python on S60 mobile phone actually) and I've noticed that it uses
absolutely tons of memory as compared to how much the data...
|
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...
|
by: Jean-Paul Calderone |
last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote:
The test doesn't demonstrate any leaks. It does demonstrate that memory
usage can remain at or near peak memory usage even after...
|
by: cham |
last post by:
Hi,
I am working on c++ in a linux system ( Fedora core 4 ),
kernel version - 2.6.11-1.1369_FC4
gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 )
In my code i am creating a vector to store...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |