Why Wasn't Memory Collected?
Why Wasn't Memory Collected?
- Subject: Why Wasn't Memory Collected?
- From: Bing Li <email@hidden>
- Date: Sun, 12 Jun 2011 02:03:52 +0800
Dear all,
I sent a large number, e.g., 200,000, of XML to a remote node. Each time,
the XML was created by the following method. Because of the large number, I
noticed the consumed memory was large (more then 1G!) from Activity Monitor.
Even after the sending was done, the memory was still kept in a high degree
without any decreasing.
However, the method below should be able to collect the consumed memory,
right? Why wasn't memory collected?
I appreciate so much for your help!
Best regards,
Bing
+ (const char *)createSendMessage:(NSString *)sourcePeerKey SPN:(NSString
*)sourcePeerName DPK:(NSString *)destinationPeerKey DPN:(NSString
*)destinationPeerName MSG:(NSString *)message
{
NSXMLElement *root = [NSXMLNode elementWithName:@"MessageRoot"];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc]
initWithRootElement:root];
[xmlDoc setVersion:@"1.0"];
[xmlDoc setCharacterEncoding:@"UTF-8"];
NSXMLElement *messageKeyElement = [NSXMLNode elementWithName:@
"MessageKey"];
[root addChild:messageKeyElement];
[messageKeyElement addChild:[NSXMLNode
textWithStringValue:[Utilities createUniqueKey]]];
NSXMLElement *commandElement = [NSXMLNode elementWithName:@
"Command"];
[root addChild:commandElement];
[commandElement addChild:[NSXMLNode textWithStringValue:@
"SendMessage"]];
NSXMLElement *sourcePeerKeyElement = [NSXMLNode elementWithName:@
"SOURCE_PEER_KEY"];
[root addChild:sourcePeerKeyElement];
[sourcePeerKeyElement addChild:[NSXMLNode
textWithStringValue:sourcePeerKey]];
NSXMLElement *sourcePeerNameElement = [NSXMLNode elementWithName:@
"XML.SOURCE_PEER_NAME"];
[root addChild:sourcePeerNameElement];
[sourcePeerNameElement addChild:[NSXMLNode
textWithStringValue:sourcePeerName]];
NSXMLElement *destinationPeerKeyElement = [NSXMLNode
elementWithName:@"XML.DESTINATION_PEER_KEY"];
[root addChild:destinationPeerKeyElement];
[destinationPeerKeyElement addChild:[NSXMLNode
textWithStringValue:destinationPeerKey]];
NSXMLElement *destinationPeerNameElement = [NSXMLNode
elementWithName:@"XML.DESTINATION_PEER_NAME"];
[root addChild:destinationPeerNameElement];
[destinationPeerNameElement addChild:[NSXMLNode
textWithStringValue:destinationPeerName]];
NSXMLElement *messageElement = [NSXMLNode elementWithName:@
"XML.MESSAGE"];
[root addChild:messageElement];
[messageElement addChild:[NSXMLNode textWithStringValue:message]];
NSData *data = [xmlDoc XMLData];
NSString *xmlStr = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding] autorelease];
xmlStr = [xmlStr stringByAppendingString:@"\n"];
const char *xmlChar = [xmlStr UTF8String];
[xmlDoc release];
return xmlChar;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden