electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » DIY Hardware and Software » ChucK programming language
Help with sporking and memory usage.
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
RobinFencott



Joined: Jul 26, 2007
Posts: 4
Location: London

PostPosted: Thu Jul 26, 2007 9:00 am    Post subject: Help with sporking and memory usage. Reply with quote  Mark this post and the followings unread

Hello.

When I spork a function, it seems not to free its memory, once the spork has finished. I'm monitoring the memory usage in the task manager, and it just spirals up and up, taking up around 800k with each new sporking.

I'm using the latest chuck version, on windows xp home.

This seems to apply to functions that include their own ugens. Is this simply a fact of life, or am I doing something stupid and inefficient in my code?

I tried using the unchuck =< at the end of the function, and also using me.exit(), but these make no difference.

I've attached a file to show you what I mean.

I'm intending to use chuck in a club environment, and want to make a program that will run for over an hour. If I use sporked functions in this way, I calculate my computer will run out of memory in a little under 17 minutes, so can anyone help me out?

kind regards.
Robin.


teddyspork2.ck
 Description:

Download
 Filename:  teddyspork2.ck
 Filesize:  1.26 KB
 Downloaded:  430 Time(s)

Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jul 26, 2007 9:18 am    Post subject: Reply with quote  Mark this post and the followings unread

You are right; garbage collection doesn't work yet. This is high on the wishlist.

In the meantime; very often there are ways around the problem, for example using Event signalling, using Events you can keep your shreds around and re-use them, meaning they'll never have to exit and so they'll never have to restart.

I don't have the time right now but later tonight today I could help you re-write your example to take advantage of events.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jul 26, 2007 9:18 am    Post subject: Reply with quote  Mark this post and the followings unread

Oh, and welcome on board!
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RobinFencott



Joined: Jul 26, 2007
Posts: 4
Location: London

PostPosted: Thu Jul 26, 2007 9:37 am    Post subject: Reply with quote  Mark this post and the followings unread

Ah, ok, fair enough.

I'll have a look at the events section of the manual...

I was already thinking about ways of sporking a single shread, and then getting it to wait for new events...but if you could give me a quick example, that would be fantastic.

I really love Chuck, and it's great to have such a supporting forum to be a part of.

Kind regards.

Robin
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jul 26, 2007 10:00 am    Post subject: Reply with quote  Mark this post and the followings unread

Oh, there I am again. Had to do groceries as I was out of coffee. I'm sure you understand :¬).

I had a quick glance at your code and it seems to me that you are sporking a function every five seconds which takes 6.75 seconds to run. Hence, due to the 1.75 seconds that they overlap you'll need two of those running in paralel.

Let's asume you make a event called "sperk" as we are replacing a spork with a event.

Now your function would look something like this;
---------------------------------------------
fun void teddy voice()
{
//defining ugens goes here
//I'd also define all my variables here

while(true)
{
//wait for the event, make sure to signal it, not broadcast, in your main shred
sperk => now;

//adjust some settings here
some_time => now;
//modulate some more settings
more_time => now;


//at this point your function will have done it's stuff, now it will go back to the beginning of the loop and wait for the next signaled "sperk" event
}
}

spork ~ teddy voice();
spork ~ teddy voice();

-------------------------------------
You could still unchuck all ugens from the dac when not used but that will only save you cpu, not memory.

Most of the time it's totally possible to write ChucK code that uses tricks like this to get around garbage. Signalling events if very usefull for that and here we only need to use them in their most simple form so if you look that up and restructure your code like I did above (you can re-use nearly all of what you wrote) you should be in business.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RobinFencott



Joined: Jul 26, 2007
Posts: 4
Location: London

PostPosted: Thu Jul 26, 2007 10:39 am    Post subject: Reply with quote  Mark this post and the followings unread

Hey Kassen, that's great, thanks a lot.

I got it working straight away, after filling out your example.

This is a very neat way to do things...and saves doing comparisons to now etc, to schedule events...good stuff!

...and I know exactly what your talking about..it's all about the coffee these days.

cheers.
Robin
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jul 26, 2007 10:41 am    Post subject: Reply with quote  Mark this post and the followings unread

Excelent. Let us know how your gig goes.
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sat Jul 28, 2007 10:54 am    Post subject: Reply with quote  Mark this post and the followings unread

Oh! This is such a great guideline for doing this in ChucK.
I'm planning to practice this issule in chuck today,
and happy to see this thread and it also inspires me lots.

I'd like to implement this with OSC also to extend to some more flexible use.
Maybe, I'll try to design some sound module in my style with basic oscillators and wiring but with some crazy tweaking functions..

^_^"
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Jul 29, 2007 7:06 am    Post subject: Reply with quote  Mark this post and the followings unread

Yeah, aside from voice-stealing event signalling can very easily give you a equivalent of voice management in traditional synths. I like it :¬)
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use