필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Speeding up deletion of an object containing an array of handle objects

조회 수: 3 (최근 30일)
JWTay
JWTay 2017년 6월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
I am developing a (handle) class that acts as a container for an array of (also handle) objects. I'm doing this so I can use the data in those objects for further analysis.
When deleting ContainerObj, MATLAB seems to take quite a long time. For example, when I'm loading 160,000 dataObjects, calling clear(ContainerObj) can take up to 30 seconds. My question is: is there a way to speed up deletion of these objects?
I have read the documentation on deleting cyclical object references, but I don't think that that applies here because the dataObjects are not linked to each other.
Example code:
classdef ContainerObj < handle
properties
Data = {};
end
methods
function addObject(obj)
obj.Data{end + 1} = dataObject;
end
end
end
classdef dataObject< handle
...
end
  댓글 수: 2
Image Analyst
Image Analyst 2017년 6월 14일
편집: Image Analyst 2017년 6월 14일
How long does it take if you use delete() instead of clear()?
This is not a static method, so have you instantiated 160,000 instances of the class in an array of those classes? When you say clear(ContainerObj) are you trying to erase the definition of the class? Or are you trying to clear the instantiated object(s) or object array?
JWTay
JWTay 2017년 10월 16일
I apologize for not getting back to you earlier.
Let me clarify with a quick example:
%Initialize the container object
dataset = ContainerObj;
%Add some data
for ii = 1:10000
dataset.addObject = dataObject;
end
%Do some analysis.
...
%We're done, clean up the workspace
clear(dataset)

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by