I can provide a comprehensive solution that addresses all aspects of this heap overflow issue.
Traceability Matrix Configuration:
The core problem is that the default traceability matrix export loads unlimited history. You need to configure history limits in your report template:
- Open the traceability matrix report configuration
- Add these parameters to the report query:
<parameter name="maxHistoryEntries" value="50"/>
<parameter name="historyDateRange" value="180"/>
<parameter name="batchSize" value="500"/>
This limits each defect to 50 history entries or 180 days, whichever is less, and processes defects in batches of 500.
Report Generation Optimization:
Modify your report generation settings to use streaming mode:
- Edit the report template XML
- Change the generation mode from ‘full’ to ‘streaming’
- Enable incremental processing:
<generation-mode>streaming</generation-mode>
<incremental>true</incremental>
<chunk-size>1000</chunk-size>
This processes the matrix in chunks rather than loading everything into memory.
JVM Tuning for Report Generation:
Your heap size increase is good, but you need additional tuning. Update your JVM parameters in polarion.properties:
java.awt.headless=true
-Xmx8g
-Xms4g
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:+ParallelRefProcEnabled
-XX:MaxMetaspaceSize=512m
The G1 garbage collector handles large heaps better than the default collector. The parallel reference processing helps with the many object references in history data.
History Limits Strategy:
For compliance reporting, you don’t need ALL history - you need complete audit trail coverage. Implement a tiered approach:
- Recent history (last 90 days): Include all status changes, comments, attachments
- Historical data (90-365 days): Include only status changes and key milestones
- Archived data (>365 days): Include only initial creation and final resolution
Configure this in your report template with conditional history loading based on defect age.
Database Query Optimization:
Add indexes to improve history query performance:
CREATE INDEX idx_history_workitem
ON work_item_history(work_item_id, timestamp);
CREATE INDEX idx_history_type
ON work_item_history(change_type, timestamp);
Faster queries mean less time holding objects in memory.
Alternative Approach - Scheduled Report Generation:
For very large matrices, use scheduled background generation:
- Configure the report to run during off-peak hours
- Increase the report generation timeout to 60 minutes
- Enable result caching so subsequent exports use cached data
- Set up email notification when generation completes
This allows the report to use more time and resources without impacting interactive users.
Compliance-Specific Configuration:
For audit requirements, create a dedicated compliance report template:
- Include only fields required for audit (status, assignee, resolution, timestamps)
- Exclude verbose fields like full descriptions and comments
- Use summary format for history instead of full detail
- Link to individual defect pages for detailed history rather than embedding everything
Auditors can drill down into specific defects if needed, but the matrix itself remains manageable.
Monitoring and Validation:
After implementing these changes:
- Enable JVM monitoring during report generation
- Watch heap usage - it should stay below 70% of max heap
- If you still see heap pressure, reduce maxHistoryEntries further
- Test with progressively larger date ranges to find your optimal settings
- Document the configuration for compliance auditors so they understand the history limits
With these optimizations, you should be able to generate comprehensive traceability matrices that meet compliance requirements without heap overflow. The key is balancing completeness with memory efficiency through proper history limits and streaming generation. If you still need more complete history for specific audits, generate targeted reports for smaller subsets of defects rather than trying to include everything in one export.