Jump to content

DavidJr.

Members
  • Content Count

    55
  • Joined

  • Last visited

Everything posted by DavidJr.

  1. To Clarify the "memory leak" answer, I always Free any object after use, unless it is created design time like the IdHTTP instance.
  2. I am not sure if it is a memory leak. Nothing else is running when I call SaveTheSolvedSlice() ... I actually do use TFileStream to write the file to disk first. That always works without a single issue. So is TFileStream blocking? What I mean by that is does it complete before moving on? function ExportSliceToBinFile(MyFileName: String): Boolean; var I: Integer; MySliceFile: TFileStream; begin if(Not DirectoryExists('tmp')) then CreateDir('tmp'); if(Not DirectoryExists('tmp\out')) then CreateDir('tmp\out'); MySliceFile := TFileStream.Create('tmp\out\'+MyFileName, fmCreate or fmOpenWrite); try FOR I := 1 TO GlobalIndex DO begin MySliceFile.WriteBuffer(GlobalSliceRecord[I], SizeOf(SLICE_RECORD)); end; Result := True; except Result := False; end; MyOPLToolPathFile.Free; end; The code above never fails...
  3. Actually, I only procedure after calling SaveTheProcessed if the return is True... so the app will not continue on a false. I edited the function above in my IDE and in this forum... I will take out those "Delays". But can you clarify on the statement regarding "wait for file"? Thank you for the tips you offered so far. I do appreciate the help.
  4. More information. The filename that's passed into the function is ALWAYS present so the while loop that checks for file existence doesn't need to be there, but for testing purposes I added it.
  5. This isn't used anywhere other than for testing and I am new to Indy/Delphi. But your comment didn't tell me anything that was helpful. If you are referring to the excessive try blocks or "Delay()" Please give me any suggestions. The Delay is really a replacement for sleep used here. procedure Delay(TickTime: Integer); var Past, Present: LongInt; begin Past := GetTickCount; repeat if MsgWaitForMultipleObjects(0, Pointer(nil)^, FALSE, (TickTime - Present), QS_ALLINPUT) <> WAIT_OBJECT_0 then Break; Application.ProcessMessages; Present := (GetTickCount - Past); until ( Present >= LongInt(TickTime) ); end; I normally do not need call a "delay" but here it it seemed to allow for the file to be loaded into a TStream as a Multipart form file field. So this was just attempt at that. I have not used Indy IdHTTP before this and I have no issues writing to files using TFileStream, but it seemed like in this case I needed to wait before Posting the file.
×