[ 
https://issues.apache.org/jira/browse/LUCENE-9617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17252200#comment-17252200
 ] 

ASF subversion and git services commented on LUCENE-9617:
---------------------------------------------------------

Commit ce130e3e00909e999e723c7ac662d164b51bc3a4 in lucene-solr's branch 
refs/heads/branch_8x from msfroh
[ https://gitbox.apache.org/repos/asf?p=lucene-solr.git;h=ce130e3 ]

LUCENE-9617: Reset lowestUnassignedFieldNumber in FieldNumbers.clear() (#2088)

* LUCENE-9617: Reset lowestUnassignedFieldNumber in FieldNumbers.clear()

FieldNumbers.clear() is called from IndexWriter.deleteAll(), which is
supposed to completely reset the state of the index. This includes
clearing all known fields.

Prior to this change, it would allocate progressively higher field
numbers, which results in larger and  larger arrays for
FieldInfos.byNumber, effectively "leaking" field numbers every time
deleteAll() is called.

Co-authored-by: Michael Froh <[email protected]>


> FieldNumbers.clear() should reset lowestUnassignedFieldNumber
> -------------------------------------------------------------
>
>                 Key: LUCENE-9617
>                 URL: https://issues.apache.org/jira/browse/LUCENE-9617
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 8.7
>            Reporter: Michael Froh
>            Priority: Minor
>          Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> A call to IndexWriter.deleteAll() should completely reset the state of the 
> index. Part of that is a call to globalFieldNumbersMap.clear(), which purges 
> all knowledge of fields by clearing name -> number and number -> name maps. 
> However, it does not reset lowestUnassignedFieldNumber.
> If we have loop that adds some documents, calls deleteAll(), adds documents, 
> etc. lowestUnassignedFieldNumber keeps counting up. Since FieldInfos 
> allocates an array for number -> FieldInfo, this array will get larger and 
> larger, effectively leaking memory.
> We can fix this by resetting lowestUnassignedFieldNumber to -1 in 
> FieldNumbers.clear().
> I'll write a unit test and attach a patch.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to