This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

inidb.tcl memory hog?

Old posts that have not been replied to for several years.
Locked
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

inidb.tcl memory hog?

Post by Zsac »

i realize its an old script, but i use the inidb.tcl script cause it makes file io quick and easy. anyways i have some scripts that use the inidb.tcl proc very aggressively and i find that my eggies memory usage skyrockets. i've done my best to look through the inidb.tcl script to try to help minimize its memory hogging... and the only thing i could come up with was to unset the array it uses to read and write from the file when its done. i also found that it is a horribly inneficient script... but hey.. whatever :) i'm just ganna paste the script rather than link it.

here are the two main functions:
proc ini_read {inifile section item} {
set item [lindex $item 0]
if {[lindex $inifile 0] == "" || [lindex $section 0] == "" || [lindex $item 0] == ""} { return "\;" }
if {![file exists $inifile]} { return "\;" }
set fileo [open $inifile r]
set sect ""
while {![eof $fileo]} {
set rline [gets $fileo]
set rline [string trim $rline]
if {$rline != "" || [string index $rline 0] != "\;"} {
if {[string index $rline 0] == "\[" && [string index $rline [expr [string length $rline] - 1]] == "\]"} {
set sect [string range $rline 1 [expr [string length $rline] - 2]]
} elseif {[string tolower $sect] == [string tolower $section]} {
set im [string tolower [string range $rline 0 [expr [string first = $rline] - 1]]]
set va [string range $rline [expr [string first = $rline] + 1] end]
set itm(${im}) $va
}
}
}
if {[array names itm [string tolower $item]] == ""} { return "\;" }
set rtrn [set itm([string tolower $item])]
array unset itm
close $fileo
return $rtrn
}

proc ini_write {inifile section item value} {
set section [lindex [string tolower $section] 0]
if {[lindex $inifile 0] == "" || [lindex $section 0] == "" || [lindex $item 0] == ""} { return 0 }
if {![file exists $inifile] || [file size $inifile] == 0} {
set filew [open $inifile w]
puts $filew "\[$section\]"
puts $filew "[string tolower $item]=$value"
close $filew; return 1
}
set fileo [open $inifile r]
set cursect ""; set sect ""
while {![eof $fileo]} {
set rline [string trim [gets $fileo]]
if {$rline != "" || [string index $rline 0] != "\;"} {
if {[string index $rline 0] == "\[" && [string index $rline [expr [string length $rline] - 1]] == "\]"} {
set cursect [string tolower [string range $rline 1 [expr [string length $rline] - 2]]]
lappend sect $cursect
} {
set im [string tolower [string range $rline 0 [expr [string first = $rline] - 1]]]
set vl [string range $rline [expr [string first = $rline] + 1] end]
lappend [join "ini $cursect" ""]($im) $vl
}
}
}
close $fileo; unset fileo
if {[lsearch $sect $section] == -1} { lappend sect $section }
set [join "ini $section" ""]([string tolower $item]) $value
set fileo [open $inifile w]
foreach sct $sect {
puts $fileo "\[$sct\]"
foreach ite [array names [join "ini $sct" ""]] {
set ite [lindex $ite 0]
set valu [set [join "ini $sct" ""]($ite)]
if {$ite != ""} {
puts $fileo "$ite=[join $valu]"
}
}
puts $fileo ""
}
close $fileo
return 1
}
you can see in the ini_read proc where i unset itm. any thoughts on this?

looks like the tabs aren't showing. here's the link:
http://www.egghelp.org/files/tcl/inidb042.tgz

thanks
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

Post by Zsac »

lame fellas. lame. :roll:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Can I ask what possesed you to send that reply?
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

Post by Zsac »

the lack of replies coupled with the amount of views.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

WHat do you expect when it's only been 6 hours 26 min.

There are loads of posts without replies, and thousands with.

Just because a question is asked, it doesn't mean we have to answer it. If we feel we want to contribute, we will, if we don't, then the post either remains unanswered, or you get replies like this.

If you expect instant help, pay a support person. This isn't a IRC cvhat room, and doesn't take place in real time.
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

Post by Zsac »

wow. i didn't expect flames here. take a shower or something slim.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I believe you have a very loose idea of life.

It my post was taken as a flame, then either you have a problem, or I am going insane (Again).

Flames go on, are usualy caused by going off topic, are 99.9% of the time are in anger and try to insult.

If I insulted you, I am sorry, however, you may need to cool it yourself, as it seems you have a short fuse.

I stated the facts. You posted, waited 6 1/2 hours, and then told us we where lame for not replying.

While I don't point the finger at you, as many people worse than this have passed through. Lame is when you expect everything for nothing.

When registering for the forum, and on the FAQ's on egghelp.org, it does state not to expect a answer, that we provide help in our spare time and are free to do as we choose. The forums software forced you to agree to this.

Enough said for now, before I do end up turning it into a flame.

FYI: The forums provides a small tags, designed for forummating posts. Just like the [ QUOTE ] tags you used to paste your code, there are also [ CODE ] tags, which will preserve the formatting.
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

Post by Zsac »

:^/ my smiley was supposed to put my comment in context... playfull. and you did more than point the time in your post.

"If you expect instant help, pay a support person. This isn't a IRC cvhat room, and doesn't take place in real time."

thats on the edge of flame... if you don't think thats a mild insult you need to throw some smileys in so its not taken wrong. cause to me, it looks like your telling me to stfu after i posted my little "where is everyone comment?".

and from there i didn't try to get out of hand. i just said i was suprised that i had gotten such a negative comment on this forum and that i thought you should relax. i mean... you didn't have to reply to my second post to begin with eh?

i hate it when people quote on forums. excuse me for doing it.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

hehe cool down boys :) ... no need to continue this argument/discussion

I used that script for a while, and I had the same experience as you Zsac. When it's beeing used heavily, it makes the memoryusage go balistic... I gave up on that script ahortly after ;).. but I seem to remember that it was some problem with files not beeing closed properly, or not beeing losed at all..
I dont have the time to look through it now (I'm on my way to the airport)... I just had to check in ;).. but I'll look at it when I get back
Zsac wrote:i hate it when people quote on forums. excuse me for doing it.
what he meant is that you can change the [ quote ] and [ /quote ] tags with [ code ] and [ /code ], this will show the tabs ;)
Elen sila lúmenn' omentielvo
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

Post by Zsac »

oh i know how to quote properly :) i just don't want to sink that low. hehe. anyways. i think i fixed my troubles. the script returns out before closing its file sometimes.

thanks for offering to look at my script bit though pap
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Zsac I think you misunderstood ppslim AND Papillon. In your original post, you put your code inside [ quote ] and [ /quote ]. But there is another tag, called [ code ], that lets you paste code and preserve formatting. It has nothing to do with quoting or sinking low. :)
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

hehe well I remembered correctly then at least :)
Elen sila lúmenn' omentielvo
Z
Zsac
Voice
Posts: 15
Joined: Sun Nov 17, 2002 10:12 pm

Post by Zsac »

oh yea i get ya. i did misunderstand pap in regards to the code and quote tags. i stand by what i said to pp :^/ this is a dead horse though.
Locked