Re: memory use increasing while running, till...
- Posted by useless_ Dec 28, 2012
- 1251 views
I am not sure you want to know of the bug. No one has asked for the code to demo the bug. The way i see it, i am a pita if i do or if i don't post it. I don't know what to do. So i am looking for a very narrow set of words in the right order that, to me, will absolve me of blame if i post the code. Cojabo encouraged me to post it, but i see that as Jeremy encouraging me to be on the dev list: it ends with me siting in a corner under a blanket.
I don't understand - blame for what? Finding a bug is not something to be blamed for.
Anyhow, I've got your demo code now and I have narrowed down the scope of where to look.
If you remove the call to reverse(), the problem doesn't happen. But it's not that simple. If one leaves the call to reverse() in, but changes match_replace() like this ...
--haystack = replace(haystack, replacement, posn, posn + needle_len) haystack = haystack[1 .. posn-1] & replacement & haystack[posn + needle_len + 1 .. $]
the problem goes away too.
So, the problem lies with the interaction of the reverse() and replace() calls. Without looking at the IL code yet, it looks like a dereference is being skipped for some reason.
I jumped at that first also. And it may indeed be correct. The bug in that notion is this: in the code, insert sleep(0) between the reverse() and replace() lines, and the bug goes away. So i suspect the dereference is a wild duck chase, and a race condition with the OS is involved. Another reason i suspect the duck chase is if you code data1 reversed, or simply don't reverse() it, match_replace() works fine (even if there is a bug in it). While thanks for patching match_replace(), but if i were to be seen pointing a finger, i'd point somewhere between reverse() and the OS.
Here is Kat's demo code that she emailed to me (sorry Kat if you wanted this code to be kept a secret but you're email didn't specify that)...
-- quickly eats up all available ram -- include std/sequence.e -- reverse include std/search.e -- match_replace sequence data1, data2, data3 data1 = "<_" while 1 do data2 = reverse(data1) data3 = match_replace('_',data2,' ') -- underscore,data2,space end while
True, but now it's your fault for posting it, and if you make a ticket, that's your fault also.
useless