C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2003, 08:53 AM
operator smooth operator smooth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 61 operator smooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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?

Reply With Quote
  #2  
Old March 8th, 2003, 08:20 PM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,327 7stud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 50 sec
Reputation Power: 9
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.

Reply With Quote
  #3  
Old March 9th, 2003, 03:13 PM
Gmorphus Gmorphus is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: ISRAEL
Posts: 35 Gmorphus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to Gmorphus
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.

Reply With Quote
  #4  
Old March 10th, 2003, 03:13 AM
operator smooth operator smooth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 61 operator smooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
My library is not only for windows, så I cannot use win32 specific API.

Reply With Quote
  #5  
Old March 12th, 2003, 12:17 PM
Gmorphus Gmorphus is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: ISRAEL
Posts: 35 Gmorphus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to Gmorphus
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

Reply With Quote
  #6  
Old March 12th, 2003, 01:15 PM
operator smooth operator smooth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 61 operator smooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Efficient memory management?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT