forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


When to loadlib and freelib?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Mon Jan 02, 2006 3:20 am    Post subject: When to loadlib and freelib? Reply with quote

If repeatedly using the same dll throughtout a program is it best to:

a.) loadlib at the start of the program, and then freelib when the program closes?

or

b.) loadlib and freelib each time the dll is needed?


What are the advantages/disadvantages to each method?

_________________
cheers

Dave
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Mon Jan 02, 2006 4:17 am    Post subject: Re: When to loadlib and freelib? Reply with quote

DaveŽ wrote:
If repeatedly using the same dll throughtout a program is it best to:

a.) loadlib at the start of the program, and then freelib when the program closes?

or

b.) loadlib and freelib each time the dll is needed?


What are the advantages/disadvantages to each method?

I'm not sure which is ideal but I do a), except that calling certain DSUs unloads some DLLs (eg. one I repeatedly use calls and unloads user32.dll), so after a call to that DSU I do a loadlib of user32.dll. Given that, perhaps b) would be better. Question Question

Cheers...

_________________
John Trappett
Back to top
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Mon Jan 02, 2006 5:01 am    Post subject: Reply with quote

I was using method B, but I was getting occasional access violation errors. I deduced that certain rapid user actions were trying to loadlib before the previous freelib had finished freeing the dll.

I think changing to method A has fixed it. <insert fingers crossed emoticon here>

_________________
cheers

Dave
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Tue Jan 03, 2006 4:31 am    Post subject: Reply with quote

I'd say it depends on the usage of the library. If the library will be accessed dozens of times in a program (say for instance in a loop) then it may be better off to loadlib and freelib one time only (start and end of application). If the library will be used seldom in the program it may be better to just call the library on the fly and then immediately close when done - this conserves memory and cpu usage.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group