Luc <
n...@no.no> wrote:
> On Fri, 23 Dec 2022 19:21:26 -0000 (UTC), Rich wrote:
>
>> > set ::dbfile "$::BASEDIR/somefile.db"
>> > set ::sqllibrary "$::BASEDIR/libtclsqlite3.so"
>> > load $::sqllibrary
>>
>> Why are you doing this above instead of "package require sqlite3"?
>
>
> I like that approach because I can bundle the .so library with the
> applications I intend to share when they're ready.
Which you can still do, while supporting "package require X". Just
include the package loader scripts, and do an approprate "lappend
auto_path" at startup.
> Including a package is less simple and lots of people may not have
> the package.
Which is noble -- but does not require you directly load the .so file.
> So what is wrong with using the .so library? Is it bad? Why? What are
> the undesired side effects?
Some of the package load scripts perform more than simply a "load
*.so". For that subset you'll not have everything you should have
available. Whether your specific use is impacted I cannot say.
Sigh... Not a useful answer in the least.
>> > foreach i [info vars] {
>> > if {[array exists $i]} {
>> > rw a /dev/shm/allvars.txt "$i [array size $i]\n"
>> > } else {
>> > rw a /dev/shm/allvars.txt "$i [strlen [set $i]]\n"
>> > }
>> > }
>>
>> What is "rw a"???
>
> rw is a proc that reads or writes to files. "rw a" is write/append.
> That piece of code above was introduced later, to investigate the
> problem that was observed before the code was introduced.
Ok, so a custom version of Tcllib's fileutil's
'::fileutil::appendToFile' proc.
> That piece of code above was introduced later, to investigate the
> problem that was observed before the code was introduced.
How did we know this fact, when you did not explicitly tell us this in
the original post?
>> The 'delete 1.0 end' should make the text widget memory usage not grow
>> forever.
>
> Well, yes, and it keeps the content visible too. Without it, the text
> widget would scroll so far down it could possibly find oil.
And consume an ever growing amount of memory....
>> In your original post you were doing something with graphs. Does
>> the graph library include a "delete/free/destroy" call that you are
>> missing?
>
> My graph library is Tk and canvas. No third-party library whatsoever.
Do you draw a new graph for each iteration?
If yes, do you delete all the old graphs objects first? If not, your
memory growth could also be an accumulation of undeleted canvas
objects.
> Is it reasonable that I have to destroy and recreate the entire GUI
> at every iteration so the application remains barely stable?
No.
> The chart is far from being visually intense or busy. It's quite simple.
> Why is it eating so much memory?
Since you have revealed almost nothing to us, why are you asking us why
it is using so much memory.
> Is there some "best practice" I am overlooking here to avoid that
> kind of pitfall?
A very likely answer is yes, but we can't help if you don't provide us
information with which to help. Pointing at
https://www.sqlite.org/tclsqlite.html does not help us see specifically
how you are doing something, and your memory leak is most likely the
direct result of something you are specifically (but unintentionally)
doing.
See if you can trim down to a minimal version that still 'leaks' --
then stop being so secretive and reveal that minimal version here.
Note also that trying to "trim down" can often reveal the cause,
because as you trim, if you suddenly have no more leak, then the last
thing you trimmed was likely the cause. So trim down in small
increments.