1. memory use increasing while running, till...


Does Eu v4.0.1.Nov28.eui.exe winxp do it's own harddrive caching?

I have an app that grows ~24k bytes per sec, i caught it at 618megabytes earlier today. Really oddly, it then did a reset and dropped to 7Mbytes and then 1.7Mbytes, and it's growing again.

The app uses few function calls, and i have run them all in test*.ex files to 100,000 or 10,000,000 iterations and had no memory increases. All i can think of now is a cache in eui.exe that is purged when it simply cannot hold any more.

The app gets() a line, munges it, then on the basis of line contents it wither writes to an open file, or closes that file and opens another to append to. The file may or may not be pre-existing when opened. The readfile is ~1.8 Gbytes, the writefiles are numerous.

useless

EDIT: the readfile is 2.8Gbytes

new topic     » topic index » view message » categorize

2. Re: memory use increasing while running, till...


If Eu doesn't return memory to the OS while it's running, then how is the reported memory use falling drastically while it's running? Is windoze caching the writes and reporting that cache as part of Eu?

useless

new topic     » goto parent     » topic index » view message » categorize

3. Re: memory use increasing while running, till...


http://designerthinking.com/EU_MEM.JPG

It kept growing in memory use.

useless

new topic     » goto parent     » topic index » view message » categorize

4. Re: memory use increasing while running, till...


And it just reset:

http://designerthinking.com/EU_MEM2.GIF

If Eu does not give memory back to the OS, how is this happening?

useless

new topic     » goto parent     » topic index » view message » categorize

5. Re: memory use increasing while running, till...

useless_ said...

Does Eu v4.0.1.Nov28.eui.exe winxp do it's own harddrive caching?

No.

Matt

new topic     » goto parent     » topic index » view message » categorize

6. Re: memory use increasing while running, till...

useless_ said...

If Eu does not give memory back to the OS, how is this happening?

On Windows, some memory allocations of sequences are cached, but there are limits. We only keep up to 2000 allocations cached, and each allocation must be 1024 bytes or less. Memory for atoms stored as doubles is allocated in chunks, and I don't think those chunks are ever actually freed back to the OS.

Matt

new topic     » goto parent     » topic index » view message » categorize

7. Re: memory use increasing while running, till...

mattlewis said...
useless_ said...

If Eu does not give memory back to the OS, how is this happening?

On Windows, some memory allocations of sequences are cached, but there are limits. We only keep up to 2000 allocations cached, and each allocation must be 1024 bytes or less. Memory for atoms stored as doubles is allocated in chunks, and I don't think those chunks are ever actually freed back to the OS.

Matt


How do i make the memory use stop growing? What is causing the memory use to increase, so that i may change the program in some way to avoid it?

A few days ago i ran into an Eu error "cannot allocate 49 bytes", then a quick stream of errors printed to screen, and windoze froze the app as it hit 2 Gbytes memory use. Eu didn't get a chance to print the offending source line to a crash file.

useless

new topic     » goto parent     » topic index » view message » categorize

8. Re: memory use increasing while running, till...


I got the app down to a demo of the bug, it's 8 lines, 184 bytes of Eu program, munges a 2-char sequence, and eats 30 megabytes of ram per second doing it.

If i had a clue anyone on Euphorum cared, i might post the code demonstrating the bug.

useless

new topic     » goto parent     » topic index » view message » categorize

9. Re: memory use increasing while running, till...

useless_ said...


I got the app down to a demo of the bug, it's 8 lines, 184 bytes of Eu program, munges a 2-char sequence, and eats 30 megabytes of ram per second doing it.

If i had a clue anyone on Euphorum cared, i might post the code demonstrating the bug.

useless



Ok, i deleted the demo code.

useless

new topic     » goto parent     » topic index » view message » categorize

10. Re: memory use increasing while running, till...

useless_ said...
useless_ said...


I got the app down to a demo of the bug, it's 8 lines, 184 bytes of Eu program, munges a 2-char sequence, and eats 30 megabytes of ram per second doing it.

If i had a clue anyone on Euphorum cared, i might post the code demonstrating the bug.

useless



Ok, i deleted the demo code.

useless

Frankly, it just seems rude and selfish to play "hide and seek" with testcases just because nobody immediately jumps at the chance to help you for free.

Nobody here monitors the forums as their full-time job. Its likely the people who could help had not even seen that code.

new topic     » goto parent     » topic index » view message » categorize

11. Re: memory use increasing while running, till...

CoJaBo2 said...
useless_ said...
useless_ said...


I got the app down to a demo of the bug, it's 8 lines, 184 bytes of Eu program, munges a 2-char sequence, and eats 30 megabytes of ram per second doing it.

If i had a clue anyone on Euphorum cared, i might post the code demonstrating the bug.

useless



Ok, i deleted the demo code.

useless

Frankly, it just seems rude and selfish to play "hide and seek" with testcases just because nobody immediately jumps at the chance to help you for free.

Nobody here monitors the forums as their full-time job. Its likely the people who could help had not even seen that code.


We've been discussing this in #euphoria, you want to just copy/paste the discussion here?

I offered the demo code to be helpful. Not only have my motives been misinterpreted, but then you attack me. They can still fix the bug without my code. They just don't want me to be useful.

useless

new topic     » goto parent     » topic index » view message » categorize

12. Re: memory use increasing while running, till...

KAT said...

We've been discussing this in #euphoria, you want to just copy/paste the discussion here?

I don't hang about in #euphoria (or anywhere in chat actually), so I didn't see the discussion or the demo code.

KAT said...

They just don't want me to be useful.

I doubt that.

Have you decided that only people in the chat room could help? Are you sure that no-one else can, for example me? We do live in different time zones and I do have other things to do beside monitor forums etc ...

new topic     » goto parent     » topic index » view message » categorize

13. Re: memory use increasing while running, till...

DerekParnell said...
KAT said...

We've been discussing this in #euphoria, you want to just copy/paste the discussion here?

I don't hang about in #euphoria (or anywhere in chat actually), so I didn't see the discussion or the demo code.

KAT said...

They just don't want me to be useful.

I doubt that.


Jim went to a lot of trouble last week to prove me useless.

DerekParnell said...

Have you decided that only people in the chat room could help? Are you sure that no-one else can, for example me? We do live in different time zones and I do have other things to do beside monitor forums etc ...


Why is it when i offer help, when i try to be helpful, when i discover a bug, narrow my project code down to the 8 lines which replicate the bug, and offer that to (collectively) you, you say i am asking for help?

useless

new topic     » goto parent     » topic index » view message » categorize

14. Re: memory use increasing while running, till...

KAT said...

Jim went to a lot of trouble last week to prove me useless.

That's not how I saw it.

KAT said...

Why is it when i offer help, when i try to be helpful, when i discover a bug, narrow my project code down to the 8 lines which replicate the bug, and offer that to (collectively) you, you say i am asking for help?

I'm making an assumption that the bug is not desired and that you'd like it to be resolved. Thus I kinda thought that you were trying to be part of the solution to help remove the mistake in Euphoria's implementation. I too, was attempting to be part of that solution. By submitting your demo code, I thought you were trying to help someone else get to the next stage of diagnosis or resolution, so it's not so much that you were personally asking for help with your application, but more that you were asking for help from whom ever to get Euphoria fixed.

new topic     » goto parent     » topic index » view message » categorize

15. Re: memory use increasing while running, till...

useless_ said...

I offered the demo code to be helpful. Not only have my motives been misinterpreted, but then you attack me. They can still fix the bug without my code. They just don't want me to be useful.

Sorry, I'll try not to be asleep the next time you find a bug. I'm sure we could fix the bug, if we knew what it was. I'm not sure even where to start looking.

Matt

new topic     » goto parent     » topic index » view message » categorize

16. Re: memory use increasing while running, till...

mattlewis said...
useless_ said...

I offered the demo code to be helpful. Not only have my motives been misinterpreted, but then you attack me. They can still fix the bug without my code. They just don't want me to be useful.

Sorry, I'll try not to be asleep the next time you find a bug. I'm sure we could fix the bug, if we knew what it was. I'm not sure even where to start looking.

Matt


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.

useless

new topic     » goto parent     » topic index » view message » categorize

17. Re: memory use increasing while running, till...

useless_ said...

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 cannot imagine why anyone would "blame" you for posting some code that is giving you trouble. If you'd prefer to air paranoid persecution theories than post code, I guess I can't stop you.

I'm pretty sure, however, that if the code remains your little secret, it's likely that the bug will take a lot longer to find and fix. No doubt you have your reasons for suspecting that no one is interested in fixing bugs in euphoria, but my imagination is failing to uncover them.

Matt

new topic     » goto parent     » topic index » view message » categorize

18. Re: memory use increasing while running, till...

KAT said...

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.

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 
new topic     » goto parent     » topic index » view message » categorize

19. Re: memory use increasing while running, till...

DerekParnell said...
KAT said...

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.

DerekParnell said...

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

new topic     » goto parent     » topic index » view message » categorize

20. Re: memory use increasing while running, till...

DerekParnell said...

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.

The problem manifests translated, too. The memory being leaked is allocated inside of sequence.e reverse:

 
	for lowr = pFrom to lLimit do 
		t[uppr] = target[lowr] -- << this line! 
		t[lowr] = target[uppr] 
		uppr -= 1 
	end for 

It happens when we copy the sequence due to a non-unique reference count. From a valgrind session on a translated version:

==4997== 7,543,928 bytes in 134,713 blocks are definitely lost in loss record 192 of 192 
==4997==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 
==4997==    by 0x40E44C: EMalloc (be_alloc.c:1065) 
==4997==    by 0x40DEAE: NewS1 (be_alloc.c:830) 
==4997==    by 0x40E0AD: SequenceCopy (be_alloc.c:894) 
==4997==    by 0x405494: _2reverse (sequence.c:121) 
==4997==    by 0x40482F: main (main-.c:310) 

Next step is to figure out why it's not being freed...

Matt

new topic     » goto parent     » topic index » view message » categorize

21. Re: memory use increasing while running, till...

mattlewis said...
DerekParnell said...

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.

The problem manifests translated, too. The memory being leaked is allocated inside of sequence.e reverse:

 
	for lowr = pFrom to lLimit do 
		t[uppr] = target[lowr] -- << this line! 
		t[lowr] = target[uppr] 
		uppr -= 1 
	end for 

It happens when we copy the sequence due to a non-unique reference count. From a valgrind session on a translated version:

==4997== 7,543,928 bytes in 134,713 blocks are definitely lost in loss record 192 of 192 
==4997==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 
==4997==    by 0x40E44C: EMalloc (be_alloc.c:1065) 
==4997==    by 0x40DEAE: NewS1 (be_alloc.c:830) 
==4997==    by 0x40E0AD: SequenceCopy (be_alloc.c:894) 
==4997==    by 0x405494: _2reverse (sequence.c:121) 
==4997==    by 0x40482F: main (main-.c:310) 

Next step is to figure out why it's not being freed...

Matt

How about try using a free(target) at the end of the reverse() function
just before the return t

just to see if it has something to do with multiple copies of target

new topic     » goto parent     » topic index » view message » categorize

22. Re: memory use increasing while running, till...

BRyan said...

How about try using a free(target) at the end of the reverse() function
just before the return t

just to see if it has something to do with multiple copies of target

No, it's definitely a problem with replace(). See ticket:830.

Matt

new topic     » goto parent     » topic index » view message » categorize

23. Re: memory use increasing while running, till...

mattlewis said...
BRyan said...

How about try using a free(target) at the end of the reverse() function
just before the return t

just to see if it has something to do with multiple copies of target

No, it's definitely a problem with replace(). See ticket:830.

Matt


What happened to the leak in reverse() at line sequence.e:565 - t[uppr] = target[lowr]?

Are there similar unfound landmines sprinkled around?

useless

new topic     » goto parent     » topic index » view message » categorize

24. Re: memory use increasing while running, till...

useless_ said...
mattlewis said...
BRyan said...

How about try using a free(target) at the end of the reverse() function
just before the return t

just to see if it has something to do with multiple copies of target

No, it's definitely a problem with replace(). See ticket:830.

Matt


What happened to the leak in reverse() at line sequence.e:565 - t[uppr] = target[lowr]?

Are there similar unfound landmines sprinkled around?

It's replace() that leaks the memory allocated by that line. The solution isn't obvious to me, so it's going to take some work to figure it out (reference counting bugs usually do).

I'd say that there probably are more leaks and bugs in the code, since we keep finding them. This bug has been there since 4.0.0.

Matt

new topic     » goto parent     » topic index » view message » categorize

25. Re: memory use increasing while running, till...

Matt: 
 
Wouldn't safe.e help you locate the leaks ? 
 
How about building a version of 4.0 with the euphoria original memory allocation 
that Rob used and compare that with the version of 4.0 that uses the new memory 
allocation method. 
 
To see if the memory leaks still occur. 
 

new topic     » goto parent     » topic index » view message » categorize

26. Re: memory use increasing while running, till...

mattlewis said...
useless_ said...


What happened to the leak in reverse() at line sequence.e:565 - t[uppr] = target[lowr]?

It's replace() that leaks the memory allocated by that line.


That doesn't sound right, that memory used in one procedure still exists to be used by another, when that second procedure may never be called. IIRC, i ran reverse() alone in the while loop and it wasn't a memory hog by itself, ditto running match_replace() by itself.

useless

new topic     » goto parent     » topic index » view message » categorize

27. Re: memory use increasing while running, till...

BRyan said...

Matt:

Wouldn't safe.e help you locate the leaks ?

How about building a version of 4.0 with the euphoria original memory allocation that Rob used and compare that with the version of 4.0 that uses the new memory allocation method.

To see if the memory leaks still occur.

In this case, no. The leaks are in the code for the euphoria back end, not in euphoria application code. Basically, at some point, the reference count of a sequence isn't being reduced when it should.

Matt

new topic     » goto parent     » topic index » view message » categorize

28. Re: memory use increasing while running, till...

useless_ said...
mattlewis said...
useless_ said...


What happened to the leak in reverse() at line sequence.e:565 - t[uppr] = target[lowr]?

It's replace() that leaks the memory allocated by that line.


That doesn't sound right, that memory used in one procedure still exists to be used by another, when that second procedure may never be called. IIRC, i ran reverse() alone in the while loop and it wasn't a memory hog by itself, ditto running match_replace() by itself.

The memory I'm referring to is the memory that's used to store a sequence. So, to your euphoria code, it's just a sequence. To the back end, it's a chunk of memory that's been allocated, to be freed up when the sequence's reference count drops to zero.

The implementation of replace() is somewhat complex, based on the data being replaced and the data replacing the old data. Add to that the complications of doing things in place vs making copies, and things get very complex. So basically, you've found a case where we're not handling the reference counts correctly in the bowels of replace().

You can find the implementation in be_runtime.c:Replace().

Matt

new topic     » goto parent     » topic index » view message » categorize

29. Re: memory use increasing while running, till...

BRyan said...

Matt: 
 
Wouldn't safe.e help you locate the leaks ? 
 
How about building a version of 4.0 with the euphoria original memory allocation 
that Rob used and compare that with the version of 4.0 that uses the new memory 
allocation method. 
 
To see if the memory leaks still occur. 
 


Different memory. Until a few days ago, i'd avoided calls to match() most of the time, by using code similar to that which Derek posted earlier in this thread. I'd just run into too many wierd issues with match() after v3.x, but this last app i coded up a few days ago i wrapped match_replace() instead of using only my code. I wrapped it to catch most of the situations that cause match (etc) to crash. The app memory use skyrocketed, and it wasn't an issue with code i wrote. This was serious, so i started this thread and spent an hour shrinking my app down to the minimum lines to cause the issue.

Just think, no one was interested till i sent code to Derek and deleted my copy. At no point did anyone ask for the code which proved there is a problem in Eu's C guts. I don't do C code. I can see problems and point at them.

useless

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu