Hello Der,
I'm trying to make a ECS in c++ and started exploring the existing material a little, going down the rabbit hole I ended up finding out about special allocators.
I think I get the theory behind the allocators, and have seen multiple (around 5) videos from cpp con and one from code::dive 2018 about allocators, and I do get that using allocators<type name> is bad and that you should use std::pmr::datat ype<typename, &(allocator) > instead.
What I specifically don't understand is what function other than : new, malloc, realloc, calloc (these are general allocators right?). do you use to get the memory in the first place? Like what is that one function that gives you a block of memory on the ram to work with so that nothing else touches it? What does the actual grabbing memory out of thin air work?
Do you like just get an array of some required size in bytes, and then deal with that ? Or is there a function that you can call so you don't have to create an array? This seems kind of contradictory?
I apologize if I make absolutely no sense, but can someone please help me out... I don't think I'm intelligent enough to figure this out on my own... usps tracking showbox speed test 2 1616 Banfa 9,065
Recognized Expert Moderator Expert
malloc, realloc, calloc*are C functions, in general you should not use them in C++.
You should be using new, the major difference is that malloc, realloc, calloc*allocate s you a block of uninitialized memory where as new allocates the block of memory and then calls the appropriate constructor on it to initialize the memory.
std::pmr is all very well but it is C++17 and there is plenty of development still going on using C++11 and C++14 so you need to know how to use new correctly.
dev7060 644
Recognized Expert Contributor
What I specifically don't understand is what function other than : new, malloc, realloc, calloc (these are general allocators right?). do you use to get the memory in the first place?
General-purpose languages provide the basic functions/keywords to be used to make software in the widest variety of application domains. Custom data structures can be made according to the needs by making use of the basic entities.
Like what is that one function that gives you a block of memory on the ram to work with so that nothing else touches it? What does the actual grabbing memory out of thin air work?
When you reserve a memory space using a variable, array, dynamic allocation, etc., it is untouchable by any program/process in regards to reallocation. No other process can reallocate that memory to something else unless the cell spaces are freed and are no more tagged as "in use". If it could, there would be no concept of memory leakage. However, that block of memory can be manipulated via manual programming using pointers. That's why pointers need to be dealt with care. Languages like Java don't make use of the pointers directly for security purposes.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: hojjatnikan |
last post by:
please help me
this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
|
by: raylopez99 |
last post by:
Dvorak is always interesting, albeit speculative. What hidden gem has
he found in Vista that helps developers? It can't be .NET/CLI, that's
been out forever.
RL
Vista rollout hides reality
Commentary: It's not about customers, it's about developers
By John C. Dvorak
Last Update: 2:44 PM ET Jan 31, 2007
|
by: Steven D'Aprano |
last post by:
Am I the only one who finds that I'm writing more documentation than code?
I recently needed to write a function to generate a rank table from a
list. That is, a list of ranks, where the rank of an item is the position
it would be in if the list were sorted:
alist = list('defabc')
ranks =
To do that, I needed to generate an index table first. In the book
|
by: David Mathog |
last post by:
There have been a series of questions about directory operations, all of
which have been answered with "there is no portable way to do this".
This raises the perfectly reasonable question, why, in this day and age,
does the C standard have no abstract and portable method for
dealing with directories? It doesn't seem like a particularly
difficult problem. For instance, this
int show_current_directory(struct DIRSTRUCT *current_directory);
|
by: stephenrussett |
last post by:
Ok i what i am trying to do is:
I have a query that pumps out information like this:
(1) (2) (3) (4) (5)
1 1 Cooper Street NS Johnson & Dale
2 2 Cooper Street NS Johnson & Dale
3 3 Cooper Street NS Johnson & Dale
4 4 Cooper Street NS Johnson & Dale
| |
by: Tiruak |
last post by:
Hi there. Thanks in advance for the people reading and trying to help.
I'm very begginer using flash and action script, and I tryed to do this one navigation menu. Since I dont have experience doing this, I did things in a way I thought it should work, to create the onmouseover animation of the buttons of my navigation menu.
After a couple days working on it, I managed it to work almost the way I wanted it to, with 2 exceptions that I...
|
by: Sreenivas |
last post by:
I dont know how to compile cpp programs with gcc as i am new to gcc
and cpp.
could anybody help me out?
Thanks&Regards,
Srinivas Reddy Thatiparthy.
|
by: shwetaT |
last post by:
i m working in php domain and i dont know much about php,so will u plz suggest me some good sites through which i learn php very well n fast
|
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,...
|
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: 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...
|
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: 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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |