memory leak
memory leak
hi
i found all the object created by the sfs framework can't be released ,i hope you can help me to solve this problem quickly, our project is really in a hurry
i found all the object created by the sfs framework can't be released ,i hope you can help me to solve this problem quickly, our project is really in a hurry
-
- Posts: 186
- Joined: 16 Oct 2011, 14:33
Re: memory leak
hi,
could you explain a bit more about what objects are you creating and if this problem is on client side or serverside?
which client api are you using as3/unity ?
generally it shouldnt be related to sfs as sfs is just an api.
if you could post a small fragment of your code where an object is not being able to release i could help.
could you explain a bit more about what objects are you creating and if this problem is on client side or serverside?
which client api are you using as3/unity ?
generally it shouldnt be related to sfs as sfs is just an api.
if you could post a small fragment of your code where an object is not being able to release i could help.
Re: memory leak
thanks for help me
i'm using the iOS api ,and the image is taked from instruments
i'm using the iOS api ,and the image is taked from instruments
- Attachments
-
- leak.jpg
- (116.37 KiB) Not downloaded yet
Last edited by maomao on 15 Mar 2012, 15:21, edited 2 times in total.
Re: memory leak
Code: Select all
- (void)viewDidLoad{
sfs = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:NO delegate:self];
[sfs connect:@"www.h-tlk.mobi" port:9933];
[super viewDidLoad];
}
-(void)onConnection:(SFSEvent *)evt{
SFSObject *object = [SFSObject newInstance];
[object putUtfString:@"login_type" value:@"1"];
LoginRequest *request = [[LoginRequest alloc] initWithUserName:@"admin" password:@"123455" zoneName:@"JKSJ" params:object];
[sfs send:request];
}
-(void)onLogin:(SFSEvent *)evt{
[sfs send:[JoinRoomRequest requestWithId:@"minihome"]];
}
-(void)onRoomJoin:(SFSEvent *)evt{
room = [evt.params objectForKey:@"room"];
[self startTest];
}
-(void)startTest{
[NSTimer scheduledTimerWithTimeInterval:.3f target:self selector:@selector(sendMsg:) userInfo:nil repeats:YES];
}
-(void)sendMsg:(id)sender{
SFSObject *object = [SFSObject newInstance];
[object putInt:@"server_code" value:9022];
ExtensionRequest *request = [ExtensionRequest requestWithExtCmd:@"sms_sys_initialization" params:object room:room];
[sfs send:request];
}
-(void)onExtensionResponse:(SFSEvent *)event{
SFSObject *object = [event.params objectForKey:@"params"];
NSString *code = [NSString stringWithFormat:@"%d",[object getInt:@"server_code"]];
NSString *str = [object getUtfString:@"server_parame"];
NSLog(@"%d:%@",code,str);
}
-(void)onRoomJoinError:(SFSEvent *)evt{
NSLog(@"rom join error");
}
-(void)onLoginError:(SFSEvent *)evt{
NSLog(@"login error");
}
Last edited by maomao on 15 Mar 2012, 15:32, edited 1 time in total.
Re: memory leak
i don't know if there is something wrong with my code ,but last version is all right for me ,just with the same code!
-
- Posts: 186
- Joined: 16 Oct 2011, 14:33
Re: memory leak
oops, m so sorry, i havnt worked with ios client...
Re: memory leak
it doesn't matter ,thanks for your reply
- A51Integrated
- Posts: 240
- Joined: 03 Jan 2012, 19:55
- Location: Toronto, Canada
- Contact:
Re: memory leak
This is noted in the release notes of the new API. SFSObject previously was created using autorelease in the API. That has since been removed to prevent XCode from throwing warnings.
The proper way to instantiate an SFSObject is
This change was implemented in SFS2XAPI v1.0.0
The proper way to instantiate an SFSObject is
Code: Select all
SFSObject *obj = [[SFSObject newInstance] autorelease];
This change was implemented in SFS2XAPI v1.0.0
A51 Integrated
http://a51integrated.com / +1 416-703-2300
http://a51integrated.com / +1 416-703-2300
Re: memory leak
hi
i've updated to the latest api and release sfsobject myself,but there isn't anything different
i've updated to the latest api and release sfsobject myself,but there isn't anything different
Code: Select all
- (void)viewDidLoad{
sfs = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:NO delegate:self];
[sfs connect:@"192.168.16.109" port:9933];
[super viewDidLoad];
}
-(void)onConnection:(SFSEvent *)evt{
SFSObject *object = [SFSObject newInstance];
[object putUtfString:@"login_type" value:@"1"];
LoginRequest *request = [[LoginRequest alloc] initWithUserName:@"admin" password:@"123455" zoneName:@"JKSJ" params:object];
[sfs send:request];
[object release];
[request release];
}
-(void)onLogin:(SFSEvent *)evt{
[sfs send:[JoinRoomRequest requestWithId:@"minihome"]];
}
-(void)onRoomJoin:(SFSEvent *)evt{
room = [evt.params objectForKey:@"room"];
[self startTest];
}
-(void)startTest{
[NSTimer scheduledTimerWithTimeInterval:.3f target:self selector:@selector(sendMsg:) userInfo:nil repeats:YES];
}
-(void)sendMsg:(id)sender{
SFSObject *object = [SFSObject newInstance];
[object putInt:@"server_code" value:9022];
ExtensionRequest *request = [ExtensionRequest requestWithExtCmd:@"sms_sys_initialization" params:object room:room];
[sfs send:request];
[object release];
}
-(void)onExtensionResponse:(SFSEvent *)event{
SFSObject *object = [event.params objectForKey:@"params"];
NSString *code = [NSString stringWithFormat:@"%d",[object getInt:@"server_code"]];
NSString *str = [object getUtfString:@"server_parame"];
NSLog(@"%@:%@",code,str);
}
- Attachments
-
- leak.jpg
- (116.37 KiB) Not downloaded yet
- A51Integrated
- Posts: 240
- Joined: 03 Jan 2012, 19:55
- Location: Toronto, Canada
- Contact:
Re: memory leak
Don't release them, autorelease them as in my previous example. You may will run into issues if you release them right after instantiation.
Re: memory leak
i use your code but it doesn't work
Code: Select all
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad{
sfs = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:NO delegate:self];
[sfs connect:@"192.168.16.109" port:9933];
[super viewDidLoad];
}
-(void)onConnection:(SFSEvent *)evt{
SFSObject *object = [[SFSObject newInstance] autorelease];
[object putUtfString:@"login_type" value:@"1"];
LoginRequest *request = [[LoginRequest alloc] initWithUserName:@"admin" password:@"123455" zoneName:@"JKSJ" params:object];
[sfs send:request];
[request release];
}
-(void)onLogin:(SFSEvent *)evt{
[sfs send:[JoinRoomRequest requestWithId:@"minihome"]];
}
-(void)onRoomJoin:(SFSEvent *)evt{
room = [evt.params objectForKey:@"room"];
[self startTest];
}
-(void)startTest{
[NSTimer scheduledTimerWithTimeInterval:.3f target:self selector:@selector(sendMsg:) userInfo:nil repeats:YES];
}
-(void)sendMsg:(id)sender{
SFSObject *object = [[SFSObject newInstance] autorelease];
[object putInt:@"server_code" value:9022];
ExtensionRequest *request = [ExtensionRequest requestWithExtCmd:@"sms_sys_initialization" params:object room:room];
[sfs send:request];
}
-(void)onExtensionResponse:(SFSEvent *)event{
SFSObject *object = [event.params objectForKey:@"params"];
NSString *code = [NSString stringWithFormat:@"%d",[object getInt:@"server_code"]];
NSString *str = [object getUtfString:@"server_parame"];
}
-(void)onRoomJoinError:(SFSEvent *)evt{
NSLog(@"rom join error");
}
-(void)onLoginError:(SFSEvent *)evt{
NSLog(@"login error");
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
- A51Integrated
- Posts: 240
- Joined: 03 Jan 2012, 19:55
- Location: Toronto, Canada
- Contact:
Re: memory leak
What doesn't work? With autorelease, the objects will be cleared when memory is required - not instantly.
Re: memory leak
you can see the image i uploaded before! all the sfsobject、datawrapper can't be released
- A51Integrated
- Posts: 240
- Joined: 03 Jan 2012, 19:55
- Location: Toronto, Canada
- Contact:
Re: memory leak
OK. There may be an issues with garbage collection in the framework. We'll have closer look.
Re: memory leak
hi
do you have any solution for the issue,we are really in a hurry
do you have any solution for the issue,we are really in a hurry
Return to “SFS2X iPhone / iPad / OSX API”
Who is online
Users browsing this forum: No registered users and 32 guests