[
https://issues.apache.org/jira/browse/THRIFT-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew McGeachie updated THRIFT-59:
-----------------------------------
Description:
The Cocoa generated code inside a struct that reads in a field that is a list
of structs leaks memory.
Here's a relevant sample from the read: of a generated struct:
{noformat}
case 3:
if (fieldType == TType_LIST) {
int _size50;
[inProtocol readListBeginReturningElementType: NULL size: &_size50];
NSMutableArray * fieldValue = [[NSMutableArray alloc]
initWithCapacity: _size50];
int _i51;
for (_i51 = 0; _i51 < _size50; ++_i51)
{
MYOBJECT *_elem52 = [[MYOBJECT alloc] init];
[_elem52 read: inProtocol];
[fieldValue addObject: _elem52];
}
[inProtocol readListEnd];
[self setNotes: fieldValue];
[fieldValue release];
} else {
[TProtocolUtil skipType: fieldType onProtocol: inProtocol];
}
break;
{noformat}
Each instance of MYOBJECT read in is created with alloc/init and then added to
the fieldValue array (which retains it) but then never released.
was:
The Cocoa generated code inside a struct that reads in a field that is a list
of structs leaks memory.
Here's a relevant sample from the read: of a generated struct:
case 3:
if (fieldType == TType_LIST) {
int _size50;
[inProtocol readListBeginReturningElementType: NULL size: &_size50];
NSMutableArray * fieldValue = [[NSMutableArray alloc]
initWithCapacity: _size50];
int _i51;
for (_i51 = 0; _i51 < _size50; ++_i51)
{
MYOBJECT *_elem52 = [[MYOBJECT alloc] init];
[_elem52 read: inProtocol];
[fieldValue addObject: _elem52];
}
[inProtocol readListEnd];
[self setNotes: fieldValue];
[fieldValue release];
} else {
[TProtocolUtil skipType: fieldType onProtocol: inProtocol];
}
break;
Each instance of MYOBJECT read in is created with alloc/init and then added to
the fieldValue array (which retains it) but then never released.
Just formatting.
> Memory leak reading lists of structs
> ------------------------------------
>
> Key: THRIFT-59
> URL: https://issues.apache.org/jira/browse/THRIFT-59
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Cocoa)
> Reporter: Andrew McGeachie
>
> The Cocoa generated code inside a struct that reads in a field that is a list
> of structs leaks memory.
> Here's a relevant sample from the read: of a generated struct:
> {noformat}
> case 3:
> if (fieldType == TType_LIST) {
> int _size50;
> [inProtocol readListBeginReturningElementType: NULL size: &_size50];
> NSMutableArray * fieldValue = [[NSMutableArray alloc]
> initWithCapacity: _size50];
> int _i51;
> for (_i51 = 0; _i51 < _size50; ++_i51)
> {
> MYOBJECT *_elem52 = [[MYOBJECT alloc] init];
> [_elem52 read: inProtocol];
> [fieldValue addObject: _elem52];
> }
> [inProtocol readListEnd];
> [self setNotes: fieldValue];
> [fieldValue release];
> } else {
> [TProtocolUtil skipType: fieldType onProtocol: inProtocol];
> }
> break;
> {noformat}
> Each instance of MYOBJECT read in is created with alloc/init and then added
> to the fieldValue array (which retains it) but then never released.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.