If you are referring to Snapshot artifacts than Artifactory has a built in mechanism for limiting the number of snapshots.
To specify the maximum number of snapshots that may be stored, in the Edit Repository dialog, select the Basic Settings tab.
You first need to check the Handle Snapshots checkbox which then enables you to set the Max Unique Snapshots field. This value is zero by default, which means that all snapshots are saved.
In addition you can cleanup artifacts by developing a custom user plugin or create an external script using the Artifactory REST API.
Artifactory supports cleanup by allowing you to write custom User Plugins which you can develop to meet your own specific cleanup requirements. There are a number of cleanup scripts on GitHub which you can use as provided or modify to suit your own needs. Please not that user plugins is a feature of the Artifactory pro version.
Using the Artifactory REST API, you may write scripts to implement virtually any custom cleanup logic. You can use the various search APIs for finding artifacts you want to delete and use the delete item API for deleting them.
For more information and examples you can take a look at Managing Disk Space Usage