NSDate -> Memory Leak

Hello!
I want to get the current date in a infinite while loop. I accomplish this by doing like this:

method LPIController.startTimer;
begin
  while true do
  begin   
    using autoreleasepool do 
    begin 
      var date:= NSDate.date;
    end;          
  end;
end;

method LPIController.setDataSource(aLPIDataSource: ILPIDataSource);
begin
  fLPIDataSource:= aLPIDataSource;
  self.performSelectorInBackground(selector(startTimer)) withObject(nil);  
end;

As you can see the “startTimer” routine runs asynchronously.
I have no idea why the Instruments shows a continuously growing great amount of NSDate. So far, I thought that the auto-release pool would release the date each pass.
Do you have any ideas of how to fix this ?

Best regards
Benny

This should do the trick. We’ll need to investigate this.

Thanks, logged as bugs://71080

Reproduced with File|New|MacApp and this code added:

method AppDelegate.applicationDidFinishLaunching(aNotification: NSNotification);
begin
  fMainWindowController := new MainWindowController();
  fMainWindowController.showWindow(nil);
  self.performSelectorInBackground(selector(startTimer)) withObject(nil);
end;

method AppDelegate.startTimer;
begin
  loop begin   
    using autoreleasepool do begin 
      var date:= NSDate.date;
    end;            
  end;
end;

the NSDates never get released:

their release flow looks like this:

#	Event Type	∆ RefCt	RefCt	Timestamp	Responsible Library	Responsible Caller
0	Malloc	+1	1	00:01.410.020	AutoreleaseLeak	-[AppDelegate startTimer]
1	Autorelease	00:01.410.040	libsystem_pthread.dylib	thread_start
2	Retain	+1	2	00:01.410.050	AutoreleaseLeak	-[AppDelegate startTimer]
3	Retain	+1	3	00:01.410.060	libsystem_pthread.dylib	thread_start
4	Release	-1	2	00:01.410.070	AutoreleaseLeak	-[AppDelegate startTimer]
5	Release	-1	1	00:01.410.080	AutoreleaseLeak	-[AppDelegate startTimer]

Definitely looks like a compiler bug. Set though prio.

Hi Mark,
is there any hotfix or workaround? I need to release an App having this issue in the next few days. Unfortunately, the current beta doesn’t address this bug.

I’ll make sure this gets looked at first thing Monday and we can shoot you an interim beta build, if needed. Sorry about this not having been fixed for today’s beta yet.

Wow, that would be fantastic! Thank you.

bugs://71080 got closed with status fixed.

If you let me know what your username on remobjects.com is (here or via private message/email to info@) i can put a new build with this fix into your Personal Downloads folder, later today.