1. Memory leaks in Exotica demos
In the Exotica demos, each one that has text output has a memory leak.
Basically, this is being done in a loop:
txt = allocate_string("Text here")
result = c_func(GDI_TEXTOUT, {x, y, txt, 0, 0, 0, 0})
Many demos have several lines like this in the main loop, and a new value is
given to txt with each call to allocate_string().
If you added another line that prints out the last value of txt, the value
of txt will increase with each loop. The main problem is that the memory
allocated is never freed, until Euphoria exits, anyway.
There are two ways to fix this. First, you can free(txt) after each call to
TEXTOUT. Second, you can poke(txt, "New text" & 0), so long as length("New
text") is less than the first allocated block.
I do something like this (untested code, the call to GDI_TEXTOUT is so you
get the idea... Not to work properly).
txtptr = allocate_string(repeat(0, 100))
procedure display(atom x, atom y, sequence text)
atom result
if length(text) > 100 then text = text[1..100] end if
poke(txtptr, text)
result = c_func(GDI_TEXTOUT, {blablabla, txtptr, blblah})
end procedure
Anyway, someone else may have caught this as well, but I figured I'd mention
it... We don't want this error to slip into any programs written in
Exotica... (As a further note, you should always free() something when you
want to allocate() or allocate_string() to it again. Either that or just
poke() the new value in, and don't worry about reallocating memory.)
2. Re: Memory leaks in Exotica demos
Robert Pilkington wrote:
>
> In the Exotica demos, each one that has text output has a memory leak.
> Basically, this is being done in a loop:
>
> txt = allocate_string("Text here")
> result = c_func(GDI_TEXTOUT, {x, y, txt, 0, 0, 0, 0})
Hi, Robert. Thanks for reporting this to the list. I never even gave
it a thought about it getting memory leaks like that. But I will take
note on that and fix the Exotica examples to at least free the memory
after the text is printed when I ever release a new version of Exotica.
-- Todd Riggins