English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 08 September 2021, 10:44   #21
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
Depends on your datastructure. We were using an array, so we just run from the back. As always with performance tuning, you have to measure the effect, to see if it really makes a difference in your case.
sparhawk is offline  
Old 08 September 2021, 11:07   #22
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by carls View Post
I don't remember actually but it was significant. Like, 10 seconds or something for maybe 1000 items.

Anyway, I rewrote the whole thing to read the entire file into a large char and then do tokenization on that, it's now almost instant instead.

PS.
Coda is a wonderful intro, one I keep returning to.

Thanks for your Coda comment It was big fun to create.


Regarding removing a 1000 items from LinkedList heap: there will be (1000-n) x (1000-n) comparisons if freeing is done in the reverse order you allocated them. If the heap is already filled with other items it will take even more comparisons. So this can take quite some time (tho 10s sounds too much to me).
pink^abyss is offline  
Old 08 September 2021, 16:44   #23
carls
Registered User
 
Join Date: Apr 2012
Location: Cyberspace
Posts: 57
Quote:
Originally Posted by pink^abyss View Post
So this can take quite some time (tho 10s sounds too much to me).

It was a singly linked list of arbitrarliy-sized malloc'd chars. I freed it by iterating from the head.


Granted, this was 6 months ago or more and I tested with many different list sizes, so my recollection of the exact performance is a bit hazy. It was at least unacceptably slow in my book.

Last edited by carls; 08 September 2021 at 18:46. Reason: spelin mestayk
carls is offline  
Old 09 September 2021, 19:41   #24
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Memory you allocated by malloc() is automatically released when the program terminates, but it is not the operating system which does that (unfortunately) but by the compiler library that provides malloc() and free(). In that sense, "you are safe" memory wise.

The reason why that works is that the compiler library implements a memory pool, and instead of releasing each memory segment individually, it just returns the entire pool to the system.

An Os-based lookalike is AllocPooled()/FreePooled() , and CreatePool()/DeletePool() to create and dispose such pools. The compiler library may not use exactly these functions, but some lookalikes.
Thomas Richter is online now  
Old 13 September 2021, 18:52   #25
carls
Registered User
 
Join Date: Apr 2012
Location: Cyberspace
Posts: 57
Quote:
Originally Posted by Thomas Richter View Post
An Os-based lookalike is AllocPooled()/FreePooled() , and CreatePool()/DeletePool() to create and dispose such pools. The compiler library may not use exactly these functions, but some lookalikes.

Thanks, reading about those now. I was wondering how that worked with the heap but I see that the pool manager allocates puddles.
carls is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
HQ2x not smooth (some pictures linked so possibly slow loading) NewDeli support.WinUAE 53 17 March 2014 12:56
linked games turrican3 support.WinUAE 5 29 July 2013 22:05
Freeing up even more RAM? Muzer project.ClassicWB 2 13 September 2009 13:42
Dragon's lair & Escape from singe's castle linked and WHDloaded problems KONEY support.Games 3 02 August 2009 16:44
Workbench 3.0 - Freeing up more memory vroom6sri support.Games 3 08 November 2005 21:54

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:16.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08901 seconds with 15 queries