Browse files

ENH: break circular reference causing memory leak in sparse array / s…

…eries / frame, GH #663
  • Loading branch information...
1 parent 07215be commit 4c3916310a86c3e4dab6d30858a984a6f4a64103 @wesm committed Jan 21, 2012
Showing with 8 additions and 6 deletions.
  1. +0 −1 pandas/sparse/array.py
  2. +0 −1 pandas/sparse/series.py
  3. +8 −4 scripts/roll_median_leak.py
View
1 pandas/sparse/array.py
@@ -135,7 +135,6 @@ def __new__(cls, data, sparse_index=None, kind='integer', fill_value=None,
# Change the class of the array to be the subclass type.
output = subarr.view(cls)
- output._sp_values = subarr
output.sp_index = sparse_index
output.fill_value = np.float64(fill_value)
return output
View
1 pandas/sparse/series.py
@@ -133,7 +133,6 @@ def __new__(cls, data, index=None, sparse_index=None, kind='block',
# Change the class of the array to be the subclass type.
output = subarr.view(cls)
- output._sp_values = subarr
output.sp_index = sparse_index
output.fill_value = np.float64(fill_value)
output.index = index
View
12 scripts/roll_median_leak.py
@@ -14,8 +14,12 @@
pid = os.getpid()
proc = psutil.Process(pid)
-s = Series(np.random.randn(10000))
+lst = SparseList()
+lst.append([5] * 5)
+lst.append(np.repeat(np.nan, 1000000))
-for _ in xrange(5):
- # print proc.get_memory_info()
- result = rolling_median(s, 1000)
+sdf = SparseDataFrame({'A' : lst.to_array()})
+
+for _ in xrange(10000):
+ print proc.get_memory_info()
+ chunk = sdf[sdf['A'] == 5]

0 comments on commit 4c39163

Please sign in to comment.