issue with love.thread

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: issue with love.thread

Post by SiENcE »

raidho36 wrote: Sat Mar 10, 2018 9:43 pm Why doesn't it makes sense? You create text so some memory has to be allocated. If it can't be allocated, the game will crash.
Ok, i can't say something against this :).

But it crashes at 1.2 gig. What pgimeno says. Or i'm wrong!? I've 16 gig and 5 gig free and 11 gig available.

Maybe windows 7 - 64 bit has some barrier for 32 bit applications :-/ ?
Attachments
memory2.png
memory2.png (23.37 KiB) Viewed 4094 times
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: issue with love.thread

Post by pgimeno »

Yeah, 32 bit applications can't address more than 31 bits. Linux has a limit of 1.5 Gb, maybe Windows actually has a limit under 2 Gb too.

As for the line, that's probably where the main thread is when one of the threads causes the crash.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: issue with love.thread

Post by SiENcE »

pgimeno wrote: Sat Mar 10, 2018 10:10 pm Yeah, 32 bit applications can't address more than 31 bits. Linux has a limit of 1.5 Gb, maybe Windows actually has a limit under 2 Gb too.

As for the line, that's probably where the main thread is when one of the threads causes the crash.
Thx for the explanation.

Hm.. the bad alloc I understand, but as love runs in sandbox lua vm...love shouldn't crash that hard. There should be a normal abort or normal error message and not a crash.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: issue with love.thread

Post by raidho36 »

Out of memory errors usually just hard crash the system. Nothing you can do about them anyway, other than say "your system doesn't have enough memory".

It crashes at 1.2 gigs because that's the maximum continuous memory chunk length on your system. It wouldn't be an issue if your memory was used across multiple objects, but it's all in a single Channel.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: issue with love.thread

Post by SiENcE »

Ok, it's a bad allocation in love 011, but in love 102 it's c++ library runtime error.

But now i want to know what i'm doing wrong. I just pass one variable from thread to mainthread. I'm not increasing an array of something.

So what is the right handling with threads? Build a thread calculate something and than delete the thread and create a new one!?

I mean, holding a thread and passing more stuff is usual. How can I limit this increase? I've no way todo it. Just doing it slower is no solution. The memory increases over time. The memory must be acclocated by the c part of love and I cannot control this. Maybe there is a problem in push and pop, not freeing memory!?
Last edited by SiENcE on Sat Mar 10, 2018 10:30 pm, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: issue with love.thread

Post by raidho36 »

Just draw data from your Channel as soon as you feed it, don't let it sit there unattended and accumulate to several gigabytes.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: issue with love.thread

Post by SiENcE »

!?

I do a push in my thread to the channel and do a pop in the main thread.
What is wrong!? Or I don't understand what you mean when you say "feed it".

Ok, maybe it's this: "pop doesn't remove the message."
https://love2d.org/wiki/Channel:pop

When i use channel:clear() in love:update it don't crash anymore :-).

But than i suspect it's clearly an Bug. A documentation or implementation bug.

Sample attached.
Attachments
threadsExample_bugfixed.love
(5.94 KiB) Downloaded 84 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: issue with love.thread

Post by raidho36 »

You push it at a rate of several million per second, and draw at a rate of just several per second. You need to draw them million times faster or feed million times slower.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: issue with love.thread

Post by SiENcE »

I always though love does this abstraction for me.
Anyway, understood now. Thanks very much!

But what is the best way to detect this rates? At which rate update is called?

:update is called at a frequence of ~ 0.015. The thread must push a bit slower. So I have to get update DT to the thread to calculate the correct frequency.

As additional check I can use channel:getCount() to determin the number of waiting messages. If messages are increasing i apply
channel:clear().

All correct?
Last edited by SiENcE on Sat Mar 10, 2018 10:58 pm, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: issue with love.thread

Post by raidho36 »

That really depends on your application, but you probably want to read all data in the channel. Just keep popping it until it's empty.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 39 guests