Csound Csound-dev Csound-tekno Search About

waveset opcode consuming memory

Date2006-02-04 13:06
FromJean-Pierre Lemoine
Subjectwaveset opcode consuming memory
Environment Csound5 (release THANKS to all the developers!!!) - Java API 
- Windows XP
After receiving a message of low virtual memory ressource, I have 
checked the memory usage of my Java program, and constated that it is 
consuming more and more memory during its execution (1 Ko each second).  
After hunting what  part of the program can be responsible, I found that 
it is the perform() API.

The loop is in the run() method of a Thread

    public void run() {
        try {
            setRunning(true);
            cs.Perform();
            cs.delete();
            setRunning(false);
        }
        catch( Exception ex ) {
            ex.printStackTrace();
        }
    }

I have then checked with CsoundVST : same behaviour. Thus, I have tried 
to isolate the opcode, and the winner is waveset
Just comment the line "asig1w waveset asig1+ab1, 0.1" in the  following 
CSD, to  have a perfect stability in memory usage.
Normal?



-d -g -odac0 -b256 -B4096 temp.orc temp.sco


sr = 44100.0
kr = 44100.0
ksmps = 1.0
nchnls = 2

zakinit 2, 2

gkchrms20 chnexport "CHRMS20",2 ; RMS
gkch20_1 chnexport "CH20_1",2 ; Evolution 1 Instrument 20
gkch20_2 chnexport "CH20_2",2 ; Evolution 2 Instrument 20
gkch20_3 chnexport "CH20_3",2 ; Evolution 3 Instrument 20
gkch20_4 chnexport "CH20_4",2 ; Evolution 4 Instrument 20

instr 1 ; Loop Segment Evolutions
gkch20_1 loopseg 0.05,0 , 0.0,0.0, 0.23,1.0, 0.5475,0.9209, 0.2225,0.0
gkch20_2 loopseg 0.0314,0 , 0.0,0.0, 0.3711,0.2905, 0.1242,1.0, 0.5047,0.0
gkch20_3 loopseg 0.0222,0 , 0.0,0.0, 0.4091,1.0, 0.5909,0.0096
gkch20_4 loopseg 0.0295,0 , 0.0,0.0, 0.1652,0.06, 0.1298,1.0, 
0.118,0.0504, 0.177,0.0, 0.2006,0.4197, 0.2094,0.0
endin

instr 20
if1 = cpspch(5.0)
if2 = cpspch(5.03)
if3 = cpspch(5.05)

iharms1 =(sr*.4) / if1    ; Limits number of harmonics in bandlimited 
pulse waveform
ab1 gbuzz 1, if1, iharms1, 1, .9,2

iharms2 =(sr*.4) / if2    ; Limits number of harmonics in bandlimited 
pulse waveform
ab2 gbuzz 1, if2, iharms2, 1, .9,2

iharms3 =(sr*.4) / if3    ; Limits number of harmonics in bandlimited 
pulse waveform
ab3 gbuzz 1, if3, iharms3, 1, .9,2

kph1 randomi 300, 3800, .1
asig1 phaser1 ab1 + ab2 + ab3, kph1, 64, .95
kph randomh 200, 5600, ( gkch20_2 * 0.9 + 0.1 )
asig2 phaser1 asig1, kph, 64, .95
asig1w waveset asig1+ab1, 0.1  ; time to buy memory if the score 
duration is very very very long

endin




f1 0.0 65536 10 1
f2 0.0 16384 11 1
i1 0 300.0
i20 0 300.0




Jean-Pierre


Date2006-02-04 13:52
FromIstvan Varga
SubjectRe: waveset opcode consuming memory
AttachmentsNone  

Date2006-02-04 14:03
FromJean-Pierre Lemoine
SubjectRe: waveset opcode consuming memory
Thanks for the explanation. As I am observing a progessive memory 
allocation during the rendering, is that true that this 50 MB are not 
allocated in one shot, at the beginning of the score event?

Jean-Pierre

Istvan Varga wrote:

>The waveset opcode allocates a buffer for storing the input signal,
>and the length of the buffer is by default p3/2 seconds (this can be
>changed with the optional length parameter). With your example and
>double precision floats, waveset allocates about 50 MB.
>
>  
>


Date2006-02-04 15:15
FromIstvan Varga
SubjectRe: waveset opcode consuming memory
AttachmentsNone  

Date2006-02-04 15:34
FromJean-Pierre Lemoine
SubjectRe: waveset opcode consuming memory
I am using 4 waveset for 300 seconds. When the score time is reaching 
150 seconds, 200 MB have been allocated and the memory consumption does 
not grow up and stays at the same level until the end of the score. 
Thus, no bug I presume, and Windows behaviour might be the answer : the 
memory block is commited when reached by the program (or something like 
that)
Thanks for helping
Jean-Pierre

Istvan Varga wrote:

>On Saturday 04 February 2006 15:03, Jean-Pierre Lemoine wrote:
>
>  
>
>>Thanks for the explanation. As I am observing a progessive memory 
>>allocation during the rendering, is that true that this 50 MB are not 
>>allocated in one shot, at the beginning of the score event?
>>    
>>
>
>It should be allocated at the beginning of the score event, but it is
>possible that Windows really allocates the memory only when it is actually
>accessed.
>However, did you run out of memory with the 300 seconds note ? The 50 MB
>should not have consumed all virtual memory, so it is still possible that
>there is a bug.
>  
>