473,378 Members | 1,469 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

memory allocation design problem

hello ya'll.
It's my 1st post here, so be gentle.

I'm trying to build my own C++ framework (just for the fun of it), I'm
happy to say that it is a great way and I really incourge people to
learn c++ and design pattern in this way.

I decided that I need to add my own memory allocation to the frame work
- and still just for the fun of it (and because it could really speed
my system and stuff).

after contemplating on the idea I had a few thoughts:

a) I should create an interface lets say "allocatable" (or something)
and classes will inherit lets say... "allocate" function (i'm open for
new names ;))
which basicly means that i'm going to lose the constructor abillty (fix
me if i'm wrong)!

b) should I overload new?

c) how can i globalize the "allocate/new/what ever" function in a way
that a new class wont need to overload the new operator - consider that
i dont know the size of the classes.

i'll be happy to read your thoughts and any other references

Oct 31 '06 #1
1 1382
ManicQin wrote:
hello ya'll.
It's my 1st post here, so be gentle.

I'm trying to build my own C++ framework (just for the fun of it), I'm
happy to say that it is a great way and I really incourge people to
learn c++ and design pattern in this way.

I decided that I need to add my own memory allocation to the frame work
- and still just for the fun of it (and because it could really speed
my system and stuff).

after contemplating on the idea I had a few thoughts:

a) I should create an interface lets say "allocatable" (or something)
and classes will inherit lets say... "allocate" function (i'm open for
new names ;))
which basicly means that i'm going to lose the constructor abillty (fix
me if i'm wrong)!
You could use a virtual constructor instead:

You'll also need placement-new:

http://www.parashift.com/c++-faq-lit...html#faq-11.10
b) should I overload new?
You can overload new on a class-by-class basis or globally, and that
may be a good idea. It really depends on the details as to what you
*should* do, however.
c) how can i globalize the "allocate/new/what ever" function in a way
that a new class wont need to overload the new operator - consider that
i dont know the size of the classes.
Compare this FAQ:

http://www.parashift.com/c++-faq-lit...html#faq-11.14
i'll be happy to read your thoughts and any other references
Start with the FAQ, then we can talk details if you have more specific
questions.

Cheers! --M

Oct 31 '06 #2

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

Similar topics

9
by: Chris S. | last post by:
Is it possible to determine how much memory is allocated by an arbitrary Python object? There doesn't seem to be anything in the docs about this, but considering that Python manages memory...
1
by: Spur | last post by:
Hi all, I implemented a memory allocation/deallocation class that logs all new/delete calls (overloaded) and remembers for each allocated block where it was allocated from (using a macro that...
15
by: berthelot samuel | last post by:
Hi, I'm trying to develop an application for modeling 3D objects from Bezier patches, but I have a memory allocation problem. Here are my structures: typedef struct _vector3 { union { struct...
9
by: Andrew Au | last post by:
Dear all, I am trying to write a piece of software that use Object Oriented design and implement it with C, I did the following == In Object.h == typedef struct ObjectStructure* Object; ...
29
by: keredil | last post by:
Hi, Will the memory allocated by malloc get released when program exits? I guess it will since when the program exits, the OS will free all the memory (global, stack, heap) used by this...
2
by: Jon Rea | last post by:
Following up on: > Any reason for creating iv dynamically? in "Re: Namespace and #Include best practises" What are the rules for when member data should be created as new memory with a member...
7
by: toton | last post by:
Hi, I have a STL vector of of characters and the character class has a Boost array of points. The things are vector<Characterchars; and class Character{ private: array<Point,Npoints; }; Now...
81
by: Peter Olcott | last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system so I am not even out of physical RAM, much...
53
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...
34
by: jacob navia | last post by:
Suppose that you have a module that always allocates memory without ever releasing it because the guy that wrote it was lazy, as lazy as me. Now, you want to reuse it in a loop. What do you do?...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.