Project

General

Profile

« Previous | Next » 

Revision fb001aff

Added by Leszek Koltunski almost 4 years ago

Plug two more memory leaks. It should be fine now.

View differences:

src/main/java/org/distorted/library/effectqueue/EffectQueue.java
418 418
      }
419 419
    }
420 420

  
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422

  
423
  public void markForDeletion()
424
    {
425
    mUBP.markForDeletion();
426
    }
427

  
421 428
///////////////////////////////////////////////////////////////////////////////////////////////////
422 429

  
423 430
  public void doWork()
src/main/java/org/distorted/library/effectqueue/UniformBlockProperties.java
94 94
    mUBO.invalidate();
95 95
    }
96 96

  
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

  
99
  void markForDeletion()
100
    {
101
    mUBO.markForDeletion();
102
    }
103

  
97 104
///////////////////////////////////////////////////////////////////////////////////////////////////
98 105

  
99 106
  void print(int num)
src/main/java/org/distorted/library/main/DistortedEffects.java
181 181
    return mQueues[num].add(effect,position);
182 182
    }
183 183

  
184
///////////////////////////////////////////////////////////////////////////////////////////////////
185
/**
186
 * Mark the underlying OpenGL object for deletion. Actual deletion will take place on the next render.
187
 */
188
  public void markForDeletion()
189
    {
190
    for( int i=0; i<EffectType.LENGTH; i++)
191
      {
192
      mQueues[i].markForDeletion();
193
      }
194
    }
195

  
184 196
///////////////////////////////////////////////////////////////////////////////////////////////////
185 197
/**
186 198
 * Return number of effects of the given type currently in the Queue.
src/main/java/org/distorted/library/main/InternalMaster.java
19 19

  
20 20
package org.distorted.library.main;
21 21

  
22
import java.util.Set;
22
import java.util.ArrayList;
23 23

  
24 24
///////////////////////////////////////////////////////////////////////////////////////////////////
25 25
/**
......
48 48

  
49 49
  static boolean toDo()
50 50
    {
51
    Set<Slave> set = InternalStackFrameList.getSet();
52
    int numSlaves = set.size();
51
    Slave slave;
52
    ArrayList<Slave> list = InternalStackFrameList.getSet();
53
    int numSlaves = list.size();
53 54

  
54
    if( numSlaves>0 )
55
    try
55 56
      {
56
      for(Slave slave: set)
57
      for(int i=0; i<numSlaves; i++)
57 58
        {
58
 			  if( slave!=null ) slave.doWork();
59
 		    }
60
 		  return true;
59
        slave = list.remove(0);
60
        if( slave!=null ) slave.doWork();
61
        }
62
      }
63
    catch(IndexOutOfBoundsException ie)
64
      {
65
      // onDestroy must have been called, ignore
61 66
      }
62 67

  
63
    return false;
68
    return numSlaves>0;
64 69
    }
65 70

  
66 71
///////////////////////////////////////////////////////////////////////////////////////////////////
67 72

  
68 73
  public static void newSlave(Slave s)
69 74
    {
70
    InternalStackFrameList.getSet().add(s);
75
    ArrayList<Slave> list = InternalStackFrameList.getSet();
76
    int num = list.size();
77
    boolean found = false;
78
    Slave tmp;
79

  
80
    try
81
      {
82
      for(int i=0; i<num; i++)
83
        {
84
        tmp = list.get(i);
85

  
86
        if( tmp==s )
87
          {
88
          found = true;
89
          break;
90
          }
91
        }
92
      }
93
    catch(IndexOutOfBoundsException ie)
94
      {
95
      // onDestroy must have been called, ignore
96
      }
97

  
98
    if( !found ) list.add(s);
71 99
    }
72 100
  }
src/main/java/org/distorted/library/main/InternalStackFrame.java
23 23

  
24 24
import java.util.ArrayList;
25 25
import java.util.HashMap;
26
import java.util.HashSet;
27 26
import java.util.LinkedList;
28
import java.util.Set;
29 27

  
30 28
///////////////////////////////////////////////////////////////////////////////////////////////////
31 29

  
......
72 70
  private long mNextNodeID;
73 71

  
74 72
  //////////////////////////////////////////////////////////////////
75
  private Set<InternalMaster.Slave> mSlaves;                      // InternalMaster
73
  private ArrayList<InternalMaster.Slave> mSlaves;                // InternalMaster
76 74

  
77 75
  ////////////////////////////////////////////////////////////////// EffectQueue
78 76
  private long mNextQueueID;                                      //
......
86 84
    mDoneList     = new LinkedList<>();
87 85
    mToDoMap      = new HashMap<>();
88 86
    mMapNodeID    = new HashMap<>();
89
    mSlaves       = new HashSet<>();
87
    mSlaves       = new ArrayList<>();
90 88
    mMapID        = new HashMap<>();
91 89
    mNextEffectsID= 0;
92 90
    mNextClientID = 0;
......
339 337

  
340 338
///////////////////////////////////////////////////////////////////////////////////////////////////
341 339

  
342
  Set<InternalMaster.Slave> getSet()
340
  ArrayList<InternalMaster.Slave> getSet()
343 341
    {
344 342
    return mSlaves;
345 343
    }
src/main/java/org/distorted/library/main/InternalStackFrameList.java
254 254

  
255 255
///////////////////////////////////////////////////////////////////////////////////////////////////
256 256

  
257
  static Set<InternalMaster.Slave> getSet()
257
  static ArrayList<InternalMaster.Slave> getSet()
258 258
    {
259 259
    return mCurrentFrame.getSet();
260 260
    }

Also available in: Unified diff