원클릭으로
memory-safety
// Delphi memory management patterns for SimpleORM - ownership, try/finally, interface refs, and common leak scenarios.
// Delphi memory management patterns for SimpleORM - ownership, try/finally, interface refs, and common leak scenarios.
| name | memory-safety |
| description | Delphi memory management patterns for SimpleORM - ownership, try/finally, interface refs, and common leak scenarios. |
| user-invocable | false |
Rules are in
.claude/rules/security.md— this skill provides patterns and examples.
var
LQuery: iSimpleQuery; // Reference counted
begin
LQuery := TSimpleQueryFiredac.New(Conn);
// Do NOT call LQuery.Free — freed automatically when ref count = 0
end;
var
LList: TObjectList<T>;
begin
LList := TObjectList<T>.Create;
try
// Use LList
finally
LList.Free;
end;
end;
LEntity := T.Create;
try
LDAO.Insert(LEntity);
finally
LEntity.Free;
end;
function CreateEntity: T;
begin
Result := T.Create;
try
// Populate Result
except
Result.Free; // Free on error only
raise;
end;
// Caller owns Result — caller must free it
end;
function CreateList: TObjectList<T>;
begin
Result := TObjectList<T>.Create;
try
for I := 0 to N do
Result.Add(CreateItem);
except
Result.Free; // Frees list AND owned objects
raise;
end;
end;
destructor TSimpleXxx.Destroy;
begin
FreeAndNil(FOwnedComponent1);
FreeAndNil(FOwnedComponent2);
// Interface fields: do NOT free (auto-managed)
inherited;
end;
LJSON := TJSONObject.ParseJSONValue(Body) as TJSONObject;
if LJSON = nil then
raise Exception.Create('Invalid JSON');
try
// Use LJSON
finally
LJSON.Free;
end;
TRttiContext is a RECORD (not class). .Create and .Free are no-ops. Do not treat it as an object.
FQuery.DataSet.DisableControls;
try
// Process dataset
finally
FQuery.DataSet.EnableControls;
end;
Validates all SimpleORM Delphi source files for Delphi 10.2 Tokyo+ compatibility. Checks inline vars, unit scoping, generics E2506, uses completeness, memory safety, .dpr structure, and conditional compilation. Run anytime to "lint" the project.
Delphi project file structure reference — .dpr vs .pas, .dproj, .res, .dfm. Templates for console and VCL projects.
CHANGELOG.md format reference and examples for the SimpleORM project.
Coding conventions and patterns for the SimpleORM Delphi project. Automatically loaded when writing or modifying Delphi code.
SimpleORM entity-to-database mapping via RTTI attributes. Complete reference for all attributes, property types, and relationship setup.
Horse/ExpxHorse integration patterns for SimpleORM — server auto-routing, client REST driver, serialization examples.