|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Efficient memory management?
I have created a library an C, and an equivalent i C# (for the .NET platform). To my surprise, the C# version is faster!
I have tracked this strange behavior to memory allocation, which for some reason is much faster in C#. I have made some optimizations which reduced number of calls to malloc() in my C code, and that helped. But I am convinced that a further improvement is possible if malloc() could be replaced with a faster memory allocation method. Does anybody know about a library for more efficient memory management than malloc() and free()? Or maybe an algorithm to somehow allocate in advance and realloc if needed? |
|
#2
|
|||
|
|||
|
In C++, you can use "new" and "delete". I don't know if they're more efficient or not, but from the descriptions of those operators, they seem like they would be.
Last edited by 7stud : March 8th, 2003 at 08:22 PM. |
|
#3
|
|||
|
|||
|
you can use the API functions (read the MSDN for furthur info):
GlobalAlloc, VirtualAlloc/Ex, HeapAlloc... that should probably help. Please let us know about it.
__________________
"Gravitation can NOT be responsible for people falling in Love" (one of the most significant characters in the history, can you guess?) Gmorph. |
|
#4
|
|||
|
|||
|
My library is not only for windows, så I cannot use win32 specific API.
|
|
#5
|
|||
|
|||
|
than you have a problem there huston
it is common knowledge that memory allocation takes relatively a lot of time. it is a good advice to do that as few as you can |
|
#6
|
|||
|
|||
|
If memory allocation can be fast in .NET, then there must be some way to make it fast in C - I would guess that some kind of memory pooling could be used?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Efficient memory management? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|