[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Memory Leak in GDO
From: |
Rene Cornils |
Subject: |
Memory Leak in GDO |
Date: |
Tue, 26 Jun 2001 17:52:22 +0200 (METDST) |
Hi there,
I encountered a significant memory leak when using GDO (base 1.0.1). Even
for very simple programs, both client and server consume more and more
memory on every transaction (the server side seems to be more affected by
this problem).
Below you can find some simple source code for demonstration.
Is this a bug or am I doing something wrong? Any help is highly
appreciated.
Thanks in advance
Rene
// --------------------
// server.h
@interface Server : NSObject
{
}
- (NSString *)doIt:(int)value;
@end
// --------------------
// server.m
#include <Foundation/Foundation.h>
#include "server.h"
@implementation Server
- (NSString *)doIt:(int)value
{
return [NSString stringWithString:@"42"];
}
@end
int main()
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
id server, serverConnection;
server = [[Server alloc] init];
NS_DURING
serverConnection = [NSConnection
newRegisteringAtName:@"server" withRootObject:server];
NS_HANDLER
NSLog(@"unable to register service");
exit(1);
NS_ENDHANDLER
[[NSRunLoop currentRunLoop] run];
[server release];
[arp release];
return 0;
}
// --------------------
// client.m
#include <stdlib.h>
#include <Foundation/Foundation.h>
#include "server.h"
int main(int argc, char** argv)
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
id serverConnection, serverObject;
int value;
NS_DURING
serverConnection = [[NSConnection
connectionWithRegisteredName:@"server" host:@"*"] retain];
if(serverConnection == nil) {
NSLog(@"couldn't connect to server (not responding)");
exit(1);
}
serverObject = [serverConnection rootProxy];
NS_HANDLER
NSLog(@"couldn't connect to server (connection refused)");
NSLog(@"%@: %@", [localException name], [localException reason]);
exit(1);
NS_ENDHANDLER
for(;;) {
NSAutoreleasePool *loopArp = [[NSAutoreleasePool alloc] init];
value = [[serverObject doIt:1969] intValue];
[loopArp release];
}
[arp release];
return 0;
}
- Memory Leak in GDO,
Rene Cornils <=