Hi,
in program I have a frequently called function (~few times per second)
that needs a comparatively big amount of local memory (~10MB) for doing
its job.
Is it faster to make that memory static so it has not to be reallocated
all the time? Or is overall performance better if that memory is freed
when the function is done. Or is this no question of performance but
rather of style, then, what is considered nicer?
Thanks
Steffen 4 1348
Steffen wrote: Is it faster to make that memory static so it has not to be reallocated all the time? Or is overall performance better if that memory is freed when the function is done.
I'm pretty sure it won't make a noticable difference in performance if
the function is only called a few times per second. The process heap
might get fragmented because of the multiple (de)allocations, though. It
all depends on the specifics of your application and platform, so it's
hard to say.
Regards
-Laurens
On Wed, 29 Jun 2005 13:00:28 +0400, Steffen <s.*********@gmx.de> wrote: in program I have a frequently called function (~few times per second) that needs a comparatively big amount of local memory (~10MB) for doing its job.
Is it faster to make that memory static so it has not to be reallocated all the time? Or is overall performance better if that memory is freed when the function is done. Or is this no question of performance but rather of style, then, what is considered nicer?
Why don't you just compare run times of both variants?
--
Maxim Yegorushkin
<fi****************@gmail.com>
Steffen wrote: Hi,
in program I have a frequently called function (~few times per second) that needs a comparatively big amount of local memory (~10MB) for doing its job.
Luckily, today's Ghz processors can call functions
~millions times/second, and 10 MB isn't very much.
Is it faster ...
Don't worry about performance in the first iteration of
a program. Just put the object(s) you need on the stack.
If performance is a problem, get a profiler and find the
real culprit. Not earlier.
HTH,
Michiel Salters
msalters wrote:
[snip] Don't worry about performance in the first iteration of a program. Just put the object(s) you need on the stack.
OTOH, if you cannot allocate 10MB on the stack, you can pre-allocate
the memory and dispense it through some form of allocator interface.
The main problem with statically allocated memory is thread-safety, but
I don't know if this is relevant to your problem. /david This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bob |
last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and...
|
by: Steve |
last post by:
Hi,
I'm using a std::vector to store a list of user defined objects. The vector
may have well over 1000 elements, and I'm suffering a performance hit. If I
use push_back I get a much worse...
|
by: Earl Higgins |
last post by:
The company where I work as a Senior Software Engineer is currently
revamping their (1991 era) "Programming and Style Guidelines", and I'm
on the committee. The company, in business for over 20...
|
by: tweak |
last post by:
When should malloc() and related functions (e.g. calloc(), realloc() )
be used?
I keep hearing to keep stuff out of memory as much as possible since
it's not as fast as when stuff is in the...
|
by: Nadav |
last post by:
Hi,
I hope this post will find it's way to some MS technical authority...
I am experienced with bought Unmanaged C++ and Managed code ( C# ), There
are some issues with the .NET framework that...
|
by: spiff |
last post by:
We are migrating from VC++ 6 to VC++ 2003. It is a plain, unmanaged application with both C and C++ source. When running the debug build, even outside the debugger, the memory allocation/deallocation...
|
by: EasyKev |
last post by:
We have been trying to upgrade all our C++ projects from VC6 to VS .Net2003
for a while (before VS 2005 arrived), and seem to be stuck now because of the
performance degradation seen for the same...
|
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: galiorenye |
last post by:
Hi,
Given this code:
A** ppA = new A*;
A *pA = NULL;
for(int i = 0; i < 10; ++i)
{
pA = ppA;
//do something with pA
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |